diff -r 3811995aad73 -r 34456cce64bb .hgignore --- a/.hgignore Wed May 18 15:54:24 2016 -0700 +++ b/.hgignore Thu May 19 13:47:42 2016 +0200 @@ -98,3 +98,6 @@ Tools/msi/obj Tools/ssl/amd64 Tools/ssl/win32 +rel/ +dbg/ +pgo/ diff -r 3811995aad73 -r 34456cce64bb .hgtags --- a/.hgtags Wed May 18 15:54:24 2016 -0700 +++ b/.hgtags Thu May 19 13:47:42 2016 +0200 @@ -161,4 +161,3 @@ 374f501f4567b7595f2ad7798aa09afa2456bb28 v3.5.0 948ef16a69513ba1ff15c9d7d0b012b949df4c80 v3.5.1rc1 37a07cee5969e6d3672583187a73cf636ff28e1b v3.5.1 -5896da372fb044e38595fb74495de1e1e7c8fb3c v3.6.0a1 diff -r 3811995aad73 -r 34456cce64bb Doc/c-api/function.rst --- a/Doc/c-api/function.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/c-api/function.rst Thu May 19 13:47:42 2016 +0200 @@ -34,9 +34,8 @@ Return a new function object associated with the code object *code*. *globals* must be a dictionary with the global variables accessible to the function. - The function's docstring and name are retrieved from the code object. *__module__* - is retrieved from *globals*. The argument defaults, annotations and closure are - set to *NULL*. *__qualname__* is set to the same value as the function's name. + The function's docstring, name and *__module__* are retrieved from the code + object, the argument defaults and closure are set to *NULL*. .. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) diff -r 3811995aad73 -r 34456cce64bb Doc/c-api/import.rst --- a/Doc/c-api/import.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/c-api/import.rst Thu May 19 13:47:42 2016 +0200 @@ -272,7 +272,7 @@ }; -.. c:var:: const struct _frozen* PyImport_FrozenModules +.. c:var:: struct _frozen* PyImport_FrozenModules This pointer is initialized to point to an array of :c:type:`struct _frozen` records, terminated by one whose members are all *NULL* or zero. When a frozen diff -r 3811995aad73 -r 34456cce64bb Doc/c-api/init.rst --- a/Doc/c-api/init.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/c-api/init.rst Thu May 19 13:47:42 2016 +0200 @@ -366,7 +366,7 @@ It is recommended that applications embedding the Python interpreter for purposes other than executing a single script pass 0 as *updatepath*, and update :data:`sys.path` themselves if desired. - See `CVE-2008-5983 `_. + See `CVE-2008-5983 `_. On versions before 3.1.3, you can achieve the same effect by manually popping the first :data:`sys.path` element after having called diff -r 3811995aad73 -r 34456cce64bb Doc/c-api/memory.rst --- a/Doc/c-api/memory.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/c-api/memory.rst Thu May 19 13:47:42 2016 +0200 @@ -165,17 +165,15 @@ behavior when requesting zero bytes, are available for allocating and releasing memory from the Python heap. -By default, these functions use :ref:`pymalloc memory allocator `. +The default memory block allocator uses the following functions: +:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`; call +``malloc(1)`` (or ``calloc(1, 1)``) when requesting zero bytes. .. warning:: The :term:`GIL ` must be held when using these functions. -.. versionchanged:: 3.6 - - The default allocator is now pymalloc instead of system :c:func:`malloc`. - .. c:function:: void* PyMem_Malloc(size_t n) Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the @@ -297,32 +295,15 @@ Enum used to identify an allocator domain. Domains: - .. c:var:: PYMEM_DOMAIN_RAW + * :c:data:`PYMEM_DOMAIN_RAW`: functions :c:func:`PyMem_RawMalloc`, + :c:func:`PyMem_RawRealloc`, :c:func:`PyMem_RawCalloc` and + :c:func:`PyMem_RawFree` + * :c:data:`PYMEM_DOMAIN_MEM`: functions :c:func:`PyMem_Malloc`, + :c:func:`PyMem_Realloc`, :c:func:`PyMem_Calloc` and :c:func:`PyMem_Free` + * :c:data:`PYMEM_DOMAIN_OBJ`: functions :c:func:`PyObject_Malloc`, + :c:func:`PyObject_Realloc`, :c:func:`PyObject_Calloc` and + :c:func:`PyObject_Free` - Functions: - - * :c:func:`PyMem_RawMalloc` - * :c:func:`PyMem_RawRealloc` - * :c:func:`PyMem_RawCalloc` - * :c:func:`PyMem_RawFree` - - .. c:var:: PYMEM_DOMAIN_MEM - - Functions: - - * :c:func:`PyMem_Malloc`, - * :c:func:`PyMem_Realloc` - * :c:func:`PyMem_Calloc` - * :c:func:`PyMem_Free` - - .. c:var:: PYMEM_DOMAIN_OBJ - - Functions: - - * :c:func:`PyObject_Malloc` - * :c:func:`PyObject_Realloc` - * :c:func:`PyObject_Calloc` - * :c:func:`PyObject_Free` .. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator) @@ -347,12 +328,18 @@ .. c:function:: void PyMem_SetupDebugHooks(void) - Setup hooks to detect bugs in the Python memory allocator functions. + Setup hooks to detect bugs in the following Python memory allocator + functions: + + - :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc`, + :c:func:`PyMem_RawCalloc`, :c:func:`PyMem_RawFree` + - :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc`, :c:func:`PyMem_Calloc`, + :c:func:`PyMem_Free` + - :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, + :c:func:`PyObject_Calloc`, :c:func:`PyObject_Free` Newly allocated memory is filled with the byte ``0xCB``, freed memory is - filled with the byte ``0xDB``. - - Runtime checks: + filled with the byte ``0xDB``. Additional checks: - Detect API violations, ex: :c:func:`PyObject_Free` called on a buffer allocated by :c:func:`PyMem_Malloc` @@ -390,9 +377,8 @@ with a fixed size of 256 KB. It falls back to :c:func:`PyMem_RawMalloc` and :c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes. -*pymalloc* is the default allocator of the :c:data:`PYMEM_DOMAIN_MEM` (ex: -:c:func:`PyObject_Malloc`) and :c:data:`PYMEM_DOMAIN_OBJ` (ex: -:c:func:`PyObject_Malloc`) domains. +*pymalloc* is the default allocator of the :c:data:`PYMEM_DOMAIN_OBJ` domain +(ex: :c:func:`PyObject_Malloc`). The arena allocator uses the following functions: diff -r 3811995aad73 -r 34456cce64bb Doc/c-api/unicode.rst --- a/Doc/c-api/unicode.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/c-api/unicode.rst Thu May 19 13:47:42 2016 +0200 @@ -613,7 +613,8 @@ This function checks that *unicode* is a Unicode object, that the index is not out of bounds, and that the object can be modified safely (i.e. that it - its reference count is one). + its reference count is one), in contrast to the macro version + :c:func:`PyUnicode_WRITE_CHAR`. .. versionadded:: 3.3 diff -r 3811995aad73 -r 34456cce64bb Doc/conf.py --- a/Doc/conf.py Wed May 18 15:54:24 2016 -0700 +++ b/Doc/conf.py Thu May 19 13:47:42 2016 +0200 @@ -17,7 +17,7 @@ # General substitutions. project = 'Python' -copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y') +copyright = '1990-%s, Python Software Foundation' % time.strftime('%Y') # We look for the Include/patchlevel.h file in the current Python source tree # and replace the values accordingly. diff -r 3811995aad73 -r 34456cce64bb Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/distutils/apiref.rst Thu May 19 13:47:42 2016 +0200 @@ -1907,9 +1907,9 @@ that is designed to run with both Python 2.x and 3.x, add:: try: - from distutils.command.build_py import build_py_2to3 as build_py + from distutils.command.build_py import build_py_2to3 as build_py except ImportError: - from distutils.command.build_py import build_py + from distutils.command.build_py import build_py to your setup.py, and later:: diff -r 3811995aad73 -r 34456cce64bb Doc/faq/design.rst --- a/Doc/faq/design.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/design.rst Thu May 19 13:47:42 2016 +0200 @@ -158,7 +158,7 @@ line = f.readline() if not line: break - ... # do something with line + ... # do something with line The reason for not allowing assignment in Python expressions is a common, hard-to-find bug in those other languages, caused by this construct: @@ -190,7 +190,7 @@ line = f.readline() while line: - ... # do something with line... + ... # do something with line... line = f.readline() The problem with this is that if you change your mind about exactly how you get @@ -203,7 +203,7 @@ ` support the iterator protocol, so you can write simply:: for line in f: - ... # do something with line... + ... # do something with line... @@ -368,7 +368,7 @@ Practical answer: -`Cython `_ and `Pyrex `_ +`Cython `_ and `Pyrex `_ compile a modified version of Python with optional annotations into C extensions. `Weave `_ makes it easy to intermingle Python and C code in various ways to increase performance. @@ -577,10 +577,8 @@ class ListWrapper: def __init__(self, the_list): self.the_list = the_list - def __eq__(self, other): return self.the_list == other.the_list - def __hash__(self): l = self.the_list result = 98767 - len(l)*555 @@ -621,7 +619,7 @@ dictionary in sorted order:: for key in sorted(mydict): - ... # do whatever with mydict[key]... + ... # do whatever with mydict[key]... How do you specify and enforce an interface spec in Python? @@ -677,11 +675,11 @@ class label(Exception): pass # declare a label try: - ... - if condition: raise label() # goto label - ... + ... + if condition: raise label() # goto label + ... except label: # where to goto - pass + pass ... This doesn't allow you to jump into the middle of a loop, but that's usually diff -r 3811995aad73 -r 34456cce64bb Doc/faq/extending.rst --- a/Doc/faq/extending.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/extending.rst Thu May 19 13:47:42 2016 +0200 @@ -42,7 +42,7 @@ .. XXX make sure these all work `Cython `_ and its relative `Pyrex -`_ are compilers +`_ are compilers that accept a slightly modified form of Python and generate the corresponding C code. Cython and Pyrex make it possible to write an extension without having to learn Python's C API. diff -r 3811995aad73 -r 34456cce64bb Doc/faq/general.rst --- a/Doc/faq/general.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/general.rst Thu May 19 13:47:42 2016 +0200 @@ -271,7 +271,7 @@ The Python project's infrastructure is located all over the world. `www.python.org `_ is graciously hosted by `Rackspace -`_, with CDN caching provided by `Fastly +`_, with CDN caching provided by `Fastly `_. `Upfront Systems `_ hosts `bugs.python.org `_. Many other Python services like `the Wiki diff -r 3811995aad73 -r 34456cce64bb Doc/faq/gui.rst --- a/Doc/faq/gui.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/gui.rst Thu May 19 13:47:42 2016 +0200 @@ -31,13 +31,13 @@ install (since it comes included with most `binary distributions `_ of Python) and use. For more info about Tk, including pointers to the source, see the -`Tcl/Tk home page `_. Tcl/Tk is fully portable to the +`Tcl/Tk home page `_. Tcl/Tk is fully portable to the Mac OS X, Windows, and Unix platforms. wxWidgets --------- -wxWidgets (https://www.wxwidgets.org) is a free, portable GUI class +wxWidgets (http://www.wxwidgets.org) is a free, portable GUI class library written in C++ that provides a native look and feel on a number of platforms, with Windows, Mac OS X, GTK, X11, all listed as current stable targets. Language bindings are available for a number @@ -72,7 +72,7 @@ The `GObject introspection bindings `_ for Python allow you to write GTK+ 3 applications. There is also a -`Python GTK+ 3 Tutorial `_. +`Python GTK+ 3 Tutorial `_. The older PyGtk bindings for the `Gtk+ 2 toolkit `_ have been implemented by James Henstridge; see . diff -r 3811995aad73 -r 34456cce64bb Doc/faq/library.rst --- a/Doc/faq/library.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/library.rst Thu May 19 13:47:42 2016 +0200 @@ -257,8 +257,7 @@ import threading, time def thread_task(name, n): - for i in range(n): - print(name, i) + for i in range(n): print(name, i) for i in range(10): T = threading.Thread(target=thread_task, args=(str(i), i)) @@ -274,8 +273,7 @@ def thread_task(name, n): time.sleep(0.001) # <--------------------! - for i in range(n): - print(name, i) + for i in range(n): print(name, i) for i in range(10): T = threading.Thread(target=thread_task, args=(str(i), i)) @@ -504,8 +502,8 @@ import struct with open(filename, "rb") as f: - s = f.read(8) - x, y, z = struct.unpack(">hhl", s) + s = f.read(8) + x, y, z = struct.unpack(">hhl", s) The '>' in the format string forces big-endian data; the letter 'h' reads one "short integer" (2 bytes), and 'l' reads one "long integer" (4 bytes) from the @@ -683,10 +681,10 @@ import urllib.request - # build the query string + ### build the query string qs = "First=Josephine&MI=Q&Last=Public" - # connect and send the server a path + ### connect and send the server a path req = urllib.request.urlopen('http://www.some-server.out-there' '/cgi-bin/some-cgi-script', data=qs) with req: @@ -742,9 +740,8 @@ ``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's some sample code:: + SENDMAIL = "/usr/sbin/sendmail" # sendmail location import os - - SENDMAIL = "/usr/sbin/sendmail" # sendmail location p = os.popen("%s -t -i" % SENDMAIL, "w") p.write("To: receiver@example.com\n") p.write("Subject: test\n") diff -r 3811995aad73 -r 34456cce64bb Doc/faq/programming.rst --- a/Doc/faq/programming.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/programming.rst Thu May 19 13:47:42 2016 +0200 @@ -28,9 +28,9 @@ PythonWin is a Python IDE that includes a GUI debugger based on pdb. The Pythonwin debugger colors breakpoints and has quite a few cool features such as debugging non-Pythonwin programs. Pythonwin is available as part of the `Python -for Windows Extensions `__ project and +for Windows Extensions `__ project and as a part of the ActivePython distribution (see -https://www.activestate.com/activepython\ ). +http://www.activestate.com/activepython\ ). `Boa Constructor `_ is an IDE and GUI builder that uses wxWidgets. It offers visual frame creation and manipulation, @@ -44,13 +44,13 @@ Pydb is a version of the standard Python debugger pdb, modified for use with DDD (Data Display Debugger), a popular graphical debugger front end. Pydb can be found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at -https://www.gnu.org/software/ddd. +http://www.gnu.org/software/ddd. There are a number of commercial Python IDEs that include graphical debuggers. They include: -* Wing IDE (https://wingware.com/) -* Komodo IDE (https://komodoide.com/) +* Wing IDE (http://wingware.com/) +* Komodo IDE (http://komodoide.com/) * PyCharm (https://www.jetbrains.com/pycharm/) @@ -63,13 +63,13 @@ warns about code complexity and style. You can get PyChecker from http://pychecker.sourceforge.net/. -`Pylint `_ is another tool that checks +`Pylint `_ is another tool that checks if a module satisfies a coding standard, and also makes it possible to write plug-ins to add a custom feature. In addition to the bug checking that PyChecker performs, Pylint offers some additional features such as checking line length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -https://docs.pylint.org/ provides a full list of Pylint's features. +http://docs.pylint.org/ provides a full list of Pylint's features. How can I create a stand-alone binary from a Python script? @@ -207,7 +207,7 @@ >>> squares = [] >>> for x in range(5): - ... squares.append(lambda: x**2) + ... squares.append(lambda: x**2) This gives you a list that contains 5 lambdas that calculate ``x**2``. You might expect that, when called, they would return, respectively, ``0``, ``1``, @@ -234,7 +234,7 @@ >>> squares = [] >>> for x in range(5): - ... squares.append(lambda n=x: n**2) + ... squares.append(lambda n=x: n**2) Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed when the lambda is defined so that it has the same value that ``x`` had at @@ -539,7 +539,7 @@ args['a'] = 'new-value' # args is a mutable dictionary args['b'] = args['b'] + 1 # change it in-place - args = {'a': 'old-value', 'b': 99} + args = {'a':' old-value', 'b': 99} func3(args) print(args['a'], args['b']) @@ -655,15 +655,16 @@ ``def`` and ``class`` statements, but in that case the value is a callable. Consider the following code:: - >>> class A: - ... pass - ... - >>> B = A - >>> a = B() - >>> b = a - >>> print(b) + class A: + pass + + B = A + + a = B() + b = a + print(b) <__main__.A object at 0x16D07CC> - >>> print(a) + print(a) <__main__.A object at 0x16D07CC> Arguably the class has a name: even though it is bound to two names and invoked @@ -1099,7 +1100,7 @@ Use the :func:`reversed` built-in function, which is new in Python 2.4:: for x in reversed(sequence): - ... # do something with x ... + ... # do something with x... This won't touch your original sequence, but build a new copy with reversed order to iterate over. @@ -1107,7 +1108,7 @@ With Python 2.3, you can use an extended slice syntax:: for x in sequence[::-1]: - ... # do something with x ... + ... # do something with x... How do you remove duplicates from a list? @@ -1115,7 +1116,7 @@ See the Python Cookbook for a long discussion of many ways to do this: - https://code.activestate.com/recipes/52560/ + http://code.activestate.com/recipes/52560/ If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as you go:: @@ -1405,7 +1406,7 @@ definition:: class C: - def meth(self, arg): + def meth (self, arg): return arg * 2 + self.attribute @@ -1438,9 +1439,9 @@ def search(obj): if isinstance(obj, Mailbox): - ... # code to search a mailbox + # ... code to search a mailbox elif isinstance(obj, Document): - ... # code to search a document + # ... code to search a document elif ... A better approach is to define a ``search()`` method on all the classes and just @@ -1448,11 +1449,11 @@ class Mailbox: def search(self): - ... # code to search a mailbox + # ... code to search a mailbox class Document: def search(self): - ... # code to search a document + # ... code to search a document obj.search() @@ -1509,7 +1510,7 @@ Use the built-in :func:`super` function:: class Derived(Base): - def meth(self): + def meth (self): super(Derived, self).meth() For version prior to 3.0, you may be using classic classes: For a class diff -r 3811995aad73 -r 34456cce64bb Doc/faq/windows.rst --- a/Doc/faq/windows.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/faq/windows.rst Thu May 19 13:47:42 2016 +0200 @@ -340,5 +340,5 @@ Simply rename the downloaded file to have the .TGZ extension, and WinZip will be able to handle it. (If your copy of WinZip doesn't, get a newer one from -https://www.winzip.com.) +http://www.winzip.com.) diff -r 3811995aad73 -r 34456cce64bb Doc/howto/cporting.rst --- a/Doc/howto/cporting.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/cporting.rst Thu May 19 13:47:42 2016 +0200 @@ -161,7 +161,7 @@ #define INITERROR return NULL - PyMODINIT_FUNC + PyObject * PyInit_myextension(void) #else diff -r 3811995aad73 -r 34456cce64bb Doc/howto/descriptor.rst --- a/Doc/howto/descriptor.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/descriptor.rst Thu May 19 13:47:42 2016 +0200 @@ -104,7 +104,7 @@ "Emulate type_getattro() in Objects/typeobject.c" v = object.__getattribute__(self, key) if hasattr(v, '__get__'): - return v.__get__(None, self) + return v.__get__(None, self) return v The important points to remember are: @@ -163,9 +163,9 @@ self.val = val >>> class MyClass(object): - ... x = RevealAccess(10, 'var "x"') - ... y = 5 - ... + x = RevealAccess(10, 'var "x"') + y = 5 + >>> m = MyClass() >>> m.x Retrieving var "x" @@ -287,15 +287,15 @@ Running the interpreter shows how the function descriptor works in practice:: >>> class D(object): - ... def f(self, x): - ... return x - ... + def f(self, x): + return x + >>> d = D() - >>> D.__dict__['f'] # Stored internally as a function + >>> D.__dict__['f'] # Stored internally as a function - >>> D.f # Get from a class becomes an unbound method + >>> D.f # Get from a class becomes an unbound method - >>> d.f # Get from an instance becomes a bound method + >>> d.f # Get from an instance becomes a bound method > The output suggests that bound and unbound methods are two different types. @@ -358,10 +358,10 @@ calls are unexciting:: >>> class E(object): - ... def f(x): - ... print(x) - ... f = staticmethod(f) - ... + def f(x): + print(x) + f = staticmethod(f) + >>> print(E.f(3)) 3 >>> print(E().f(3)) @@ -371,23 +371,23 @@ :func:`staticmethod` would look like this:: class StaticMethod(object): - "Emulate PyStaticMethod_Type() in Objects/funcobject.c" + "Emulate PyStaticMethod_Type() in Objects/funcobject.c" - def __init__(self, f): - self.f = f + def __init__(self, f): + self.f = f - def __get__(self, obj, objtype=None): - return self.f + def __get__(self, obj, objtype=None): + return self.f Unlike static methods, class methods prepend the class reference to the argument list before calling the function. This format is the same for whether the caller is an object or a class:: >>> class E(object): - ... def f(klass, x): - ... return klass.__name__, x - ... f = classmethod(f) - ... + def f(klass, x): + return klass.__name__, x + f = classmethod(f) + >>> print(E.f(3)) ('E', 3) >>> print(E().f(3)) @@ -419,15 +419,15 @@ :func:`classmethod` would look like this:: class ClassMethod(object): - "Emulate PyClassMethod_Type() in Objects/funcobject.c" + "Emulate PyClassMethod_Type() in Objects/funcobject.c" - def __init__(self, f): - self.f = f + def __init__(self, f): + self.f = f - def __get__(self, obj, klass=None): - if klass is None: - klass = type(obj) - def newfunc(*args): - return self.f(klass, *args) - return newfunc + def __get__(self, obj, klass=None): + if klass is None: + klass = type(obj) + def newfunc(*args): + return self.f(klass, *args) + return newfunc diff -r 3811995aad73 -r 34456cce64bb Doc/howto/functional.rst --- a/Doc/howto/functional.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/functional.rst Thu May 19 13:47:42 2016 +0200 @@ -395,14 +395,14 @@ continue # Skip this element for expr2 in sequence2: if not (condition2): - continue # Skip this element + continue # Skip this element ... for exprN in sequenceN: - if not (conditionN): - continue # Skip this element + if not (conditionN): + continue # Skip this element - # Output the value of - # the expression. + # Output the value of + # the expression. This means that when there are multiple ``for...in`` clauses but no ``if`` clauses, the length of the resulting output will be equal to the product of the @@ -1225,9 +1225,9 @@ Mertz also wrote a 3-part series of articles on functional programming for IBM's DeveloperWorks site; see -`part 1 `__, -`part 2 `__, and -`part 3 `__, +`part 1 `__, +`part 2 `__, and +`part 3 `__, Python documentation diff -r 3811995aad73 -r 34456cce64bb Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/logging-cookbook.rst Thu May 19 13:47:42 2016 +0200 @@ -63,7 +63,6 @@ def __init__(self): self.logger = logging.getLogger('spam_application.auxiliary.Auxiliary') self.logger.info('creating an instance of Auxiliary') - def do_something(self): self.logger.info('doing something') a = 1 + 1 @@ -361,7 +360,7 @@ An example of using these two classes follows (imports omitted):: - que = queue.Queue(-1) # no limit on size + que = queue.Queue(-1) # no limit on size queue_handler = QueueHandler(que) handler = logging.StreamHandler() listener = QueueListener(que, handler) @@ -657,21 +656,21 @@ return True if __name__ == '__main__': - levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) - logging.basicConfig(level=logging.DEBUG, - format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') - a1 = logging.getLogger('a.b.c') - a2 = logging.getLogger('d.e.f') - - f = ContextFilter() - a1.addFilter(f) - a2.addFilter(f) - a1.debug('A debug message') - a1.info('An info message with %s', 'some parameters') - for x in range(10): - lvl = choice(levels) - lvlname = logging.getLevelName(lvl) - a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') + levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') + a1 = logging.getLogger('a.b.c') + a2 = logging.getLogger('d.e.f') + + f = ContextFilter() + a1.addFilter(f) + a2.addFilter(f) + a1.debug('A debug message') + a1.info('An info message with %s', 'some parameters') + for x in range(10): + lvl = choice(levels) + lvlname = logging.getLevelName(lvl) + a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') which, when run, produces something like:: @@ -765,10 +764,10 @@ while True: try: record = queue.get() - if record is None: # We send this as a sentinel to tell the listener to quit. + if record is None: # We send this as a sentinel to tell the listener to quit. break logger = logging.getLogger(record.name) - logger.handle(record) # No level or filter logic applied - just do it! + logger.handle(record) # No level or filter logic applied - just do it! except Exception: import sys, traceback print('Whoops! Problem:', file=sys.stderr) @@ -791,11 +790,10 @@ # Note that on Windows you can't rely on fork semantics, so each process # will run the logging configuration code when it starts. def worker_configurer(queue): - h = logging.handlers.QueueHandler(queue) # Just the one handler needed + h = logging.handlers.QueueHandler(queue) # Just the one handler needed root = logging.getLogger() root.addHandler(h) - # send all messages, for demo; no other level or filter logic applied. - root.setLevel(logging.DEBUG) + root.setLevel(logging.DEBUG) # send all messages, for demo; no other level or filter logic applied. # This is the worker process top-level loop, which just logs ten events with # random intervening delays before terminating. @@ -823,7 +821,7 @@ workers = [] for i in range(10): worker = multiprocessing.Process(target=worker_process, - args=(queue, worker_configurer)) + args=(queue, worker_configurer)) workers.append(worker) worker.start() for w in workers: @@ -1247,12 +1245,12 @@ of queues, for example a ZeroMQ 'publish' socket. In the example below,the socket is created separately and passed to the handler (as its 'queue'):: - import zmq # using pyzmq, the Python binding for ZeroMQ - import json # for serializing records portably + import zmq # using pyzmq, the Python binding for ZeroMQ + import json # for serializing records portably ctx = zmq.Context() - sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value - sock.bind('tcp://*:5556') # or wherever + sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value + sock.bind('tcp://*:5556') # or wherever class ZeroMQSocketHandler(QueueHandler): def enqueue(self, record): @@ -1290,7 +1288,7 @@ def __init__(self, uri, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx, zmq.SUB) - socket.setsockopt(zmq.SUBSCRIBE, '') # subscribe to everything + socket.setsockopt(zmq.SUBSCRIBE, '') # subscribe to everything socket.connect(uri) def dequeue(self): @@ -1636,11 +1634,11 @@ Inserting a BOM into messages sent to a SysLogHandler ----------------------------------------------------- -`RFC 5424 `_ requires that a +`RFC 5424 `_ requires that a Unicode message be sent to a syslog daemon as a set of bytes which have the following structure: an optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the `relevant -section of the specification `_.) +section of the specification `_.) In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but @@ -2118,7 +2116,7 @@ Format an exception so that it prints on a single line. """ result = super(OneLineExceptionFormatter, self).formatException(exc_info) - return repr(result) # or format into one line however you want to + return repr(result) # or format into one line however you want to def format(self, record): s = super(OneLineExceptionFormatter, self).format(record) @@ -2233,7 +2231,7 @@ The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about -to log at, and then actually logging a message at that level. You can pass a +to log at, and then actually logging a message that that level. You can pass a parameter to ``foo`` which, if true, will log at ERROR and CRITICAL levels - otherwise, it only logs at DEBUG, INFO and WARNING levels. diff -r 3811995aad73 -r 34456cce64bb Doc/howto/logging.rst --- a/Doc/howto/logging.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/logging.rst Thu May 19 13:47:42 2016 +0200 @@ -103,8 +103,8 @@ A very simple example is:: import logging - logging.warning('Watch out!') # will print a message to the console - logging.info('I told you so') # will not print anything + logging.warning('Watch out!') # will print a message to the console + logging.info('I told you so') # will not print anything If you type these lines into a script and run it, you'll see:: diff -r 3811995aad73 -r 34456cce64bb Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/pyporting.rst Thu May 19 13:47:42 2016 +0200 @@ -427,10 +427,10 @@ .. _Futurize: http://python-future.org/automatic_conversion.html .. _importlib: https://docs.python.org/3/library/importlib.html#module-importlib .. _importlib2: https://pypi.python.org/pypi/importlib2 -.. _Modernize: https://python-modernize.readthedocs.org/en/latest/ +.. _Modernize: http://python-modernize.readthedocs.org/en/latest/ .. _Porting to Python 3: http://python3porting.com/ .. _Pylint: https://pypi.python.org/pypi/pylint -.. _Python 3 Q & A: https://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html +.. _Python 3 Q & A: http://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html .. _python-future: http://python-future.org/ .. _python-porting: https://mail.python.org/mailman/listinfo/python-porting diff -r 3811995aad73 -r 34456cce64bb Doc/howto/regex.rst --- a/Doc/howto/regex.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/regex.rst Thu May 19 13:47:42 2016 +0200 @@ -1115,19 +1115,19 @@ Here's a simple example of using the :meth:`sub` method. It replaces colour names with the word ``colour``:: - >>> p = re.compile('(blue|white|red)') - >>> p.sub('colour', 'blue socks and red shoes') + >>> p = re.compile( '(blue|white|red)') + >>> p.sub( 'colour', 'blue socks and red shoes') 'colour socks and colour shoes' - >>> p.sub('colour', 'blue socks and red shoes', count=1) + >>> p.sub( 'colour', 'blue socks and red shoes', count=1) 'colour socks and red shoes' The :meth:`subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were performed:: - >>> p = re.compile('(blue|white|red)') - >>> p.subn('colour', 'blue socks and red shoes') + >>> p = re.compile( '(blue|white|red)') + >>> p.subn( 'colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) - >>> p.subn('colour', 'no colours at all') + >>> p.subn( 'colour', 'no colours at all') ('no colours at all', 0) Empty matches are replaced only when they're not adjacent to a previous match. diff -r 3811995aad73 -r 34456cce64bb Doc/howto/sorting.rst --- a/Doc/howto/sorting.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/sorting.rst Thu May 19 13:47:42 2016 +0200 @@ -262,11 +262,7 @@ twice: >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)] - >>> standard_way = sorted(data, key=itemgetter(0), reverse=True) - >>> double_reversed = list(reversed(sorted(reversed(data), key=itemgetter(0)))) - >>> assert standard_way == double_reversed - >>> standard_way - [('red', 1), ('red', 2), ('blue', 1), ('blue', 2)] + >>> assert sorted(data, reverse=True) == list(reversed(sorted(reversed(data)))) * The sort routines are guaranteed to use :meth:`__lt__` when making comparisons between two objects. So, it is easy to add a standard sort order to a class by diff -r 3811995aad73 -r 34456cce64bb Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/unicode.rst Thu May 19 13:47:42 2016 +0200 @@ -214,7 +214,7 @@ origin and development of Unicode is also available on the site. To help understand the standard, Jukka Korpela has written `an introductory -guide `_ to reading the +guide `_ to reading the Unicode character tables. Another `good introductory article `_ @@ -687,7 +687,7 @@ # make changes to the string 'data' with open(fname + '.new', 'w', - encoding="ascii", errors="surrogateescape") as f: + encoding="ascii", errors="surrogateescape") as f: f.write(data) The ``surrogateescape`` error handler will decode any non-ASCII bytes diff -r 3811995aad73 -r 34456cce64bb Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/howto/urllib2.rst Thu May 19 13:47:42 2016 +0200 @@ -122,7 +122,7 @@ Note that other encodings are sometimes required (e.g. for file upload from HTML forms - see `HTML Specification, Form Submission -`_ for more +`_ for more details). If you do not pass the ``data`` argument, urllib uses a **GET** request. One @@ -175,10 +175,10 @@ url = 'http://www.someserver.com/cgi-bin/register.cgi' user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' - values = {'name': 'Michael Foord', - 'location': 'Northampton', - 'language': 'Python' } - headers = {'User-Agent': user_agent} + values = {'name' : 'Michael Foord', + 'location' : 'Northampton', + 'language' : 'Python' } + headers = { 'User-Agent' : user_agent } data = urllib.parse.urlencode(values) data = data.encode('ascii') @@ -215,7 +215,7 @@ >>> req = urllib.request.Request('http://www.pretend_server.org') >>> try: urllib.request.urlopen(req) ... except urllib.error.URLError as e: - ... print(e.reason) #doctest: +SKIP + ... print(e.reason) #doctest: +SKIP ... (4, 'getaddrinfo failed') @@ -372,7 +372,7 @@ :: from urllib.request import Request, urlopen - from urllib.error import URLError + from urllib.error import URLError req = Request(someurl) try: response = urlopen(req) @@ -403,7 +403,7 @@ :class:`http.client.HTTPMessage` instance. Typical headers include 'Content-length', 'Content-type', and so on. See the -`Quick Reference to HTTP Headers `_ +`Quick Reference to HTTP Headers `_ for a useful listing of HTTP headers with brief explanations of their meaning and use. @@ -586,5 +586,5 @@ scripts with a localhost server, I have to prevent urllib from using the proxy. .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe - `_. + `_. diff -r 3811995aad73 -r 34456cce64bb Doc/includes/shoddy.c --- a/Doc/includes/shoddy.c Wed May 18 15:54:24 2016 -0700 +++ b/Doc/includes/shoddy.c Thu May 19 13:47:42 2016 +0200 @@ -23,7 +23,7 @@ static int Shoddy_init(Shoddy *self, PyObject *args, PyObject *kwds) { - if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0) + if (_PyType_CallInit(&PyList_Type, (PyObject *)self, args, kwds) < 0) return -1; self->state = 0; return 0; diff -r 3811995aad73 -r 34456cce64bb Doc/install/index.rst --- a/Doc/install/index.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/install/index.rst Thu May 19 13:47:42 2016 +0200 @@ -1012,7 +1012,7 @@ .. seealso:: - `C++Builder Compiler `_ + `C++Builder Compiler `_ Information about the free C++ compiler from Borland, including links to the download pages. @@ -1055,7 +1055,7 @@ for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find a good program for this task at -https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). +http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) @@ -1093,7 +1093,7 @@ .. [#] This also means you could replace all existing COFF-libraries with OMF-libraries of the same name. -.. [#] Check https://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more +.. [#] Check http://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more information .. [#] Then you have no POSIX emulation available, but you also don't need diff -r 3811995aad73 -r 34456cce64bb Doc/library/argparse.rst --- a/Doc/library/argparse.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/argparse.rst Thu May 19 13:47:42 2016 +0200 @@ -35,10 +35,10 @@ parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', - help='an integer for the accumulator') + help='an integer for the accumulator') parser.add_argument('--sum', dest='accumulate', action='store_const', - const=sum, default=max, - help='sum the integers (default: find the max)') + const=sum, default=max, + help='sum the integers (default: find the max)') args = parser.parse_args() print(args.accumulate(args.integers)) @@ -488,7 +488,7 @@ arguments they contain. For example:: >>> with open('args.txt', 'w') as fp: - ... fp.write('-f\nbar') + ... fp.write('-f\nbar') >>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@') >>> parser.add_argument('-f') >>> parser.parse_args(['-f', 'foo', '@args.txt']) @@ -725,7 +725,7 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', action='store_const', const=42) - >>> parser.parse_args(['--foo']) + >>> parser.parse_args('--foo'.split()) Namespace(foo=42) * ``'store_true'`` and ``'store_false'`` - These are special cases of @@ -766,7 +766,7 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--verbose', '-v', action='count') - >>> parser.parse_args(['-vvv']) + >>> parser.parse_args('-vvv'.split()) Namespace(verbose=3) * ``'help'`` - This prints a complete help message for all the options in the @@ -841,11 +841,11 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', nargs='?', const='c', default='d') >>> parser.add_argument('bar', nargs='?', default='d') - >>> parser.parse_args(['XX', '--foo', 'YY']) + >>> parser.parse_args('XX --foo YY'.split()) Namespace(bar='XX', foo='YY') - >>> parser.parse_args(['XX', '--foo']) + >>> parser.parse_args('XX --foo'.split()) Namespace(bar='XX', foo='c') - >>> parser.parse_args([]) + >>> parser.parse_args(''.split()) Namespace(bar='d', foo='d') One of the more common uses of ``nargs='?'`` is to allow optional input and @@ -881,9 +881,9 @@ >>> parser = argparse.ArgumentParser(prog='PROG') >>> parser.add_argument('foo', nargs='+') - >>> parser.parse_args(['a', 'b']) + >>> parser.parse_args('a b'.split()) Namespace(foo=['a', 'b']) - >>> parser.parse_args([]) + >>> parser.parse_args(''.split()) usage: PROG [-h] foo [foo ...] PROG: error: too few arguments @@ -938,9 +938,9 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', default=42) - >>> parser.parse_args(['--foo', '2']) + >>> parser.parse_args('--foo 2'.split()) Namespace(foo='2') - >>> parser.parse_args([]) + >>> parser.parse_args(''.split()) Namespace(foo=42) If the ``default`` value is a string, the parser parses the value as if it @@ -959,9 +959,9 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument('foo', nargs='?', default=42) - >>> parser.parse_args(['a']) + >>> parser.parse_args('a'.split()) Namespace(foo='a') - >>> parser.parse_args([]) + >>> parser.parse_args(''.split()) Namespace(foo=42) @@ -1018,9 +1018,9 @@ ... >>> parser = argparse.ArgumentParser(prog='PROG') >>> parser.add_argument('foo', type=perfect_square) - >>> parser.parse_args(['9']) + >>> parser.parse_args('9'.split()) Namespace(foo=9) - >>> parser.parse_args(['7']) + >>> parser.parse_args('7'.split()) usage: PROG [-h] foo PROG: error: argument foo: '7' is not a perfect square @@ -1029,9 +1029,9 @@ >>> parser = argparse.ArgumentParser(prog='PROG') >>> parser.add_argument('foo', type=int, choices=range(5, 10)) - >>> parser.parse_args(['7']) + >>> parser.parse_args('7'.split()) Namespace(foo=7) - >>> parser.parse_args(['11']) + >>> parser.parse_args('11'.split()) usage: PROG [-h] {5,6,7,8,9} PROG: error: argument foo: invalid choice: 11 (choose from 5, 6, 7, 8, 9) @@ -1109,10 +1109,10 @@ >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('--foo', action='store_true', - ... help='foo the bars before frobbling') + ... help='foo the bars before frobbling') >>> parser.add_argument('bar', nargs='+', - ... help='one of the bars to be frobbled') - >>> parser.parse_args(['-h']) + ... help='one of the bars to be frobbled') + >>> parser.parse_args('-h'.split()) usage: frobble [-h] [--foo] bar [bar ...] positional arguments: @@ -1129,7 +1129,7 @@ >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('bar', nargs='?', type=int, default=42, - ... help='the bar to %(prog)s (default: %(default)s)') + ... help='the bar to %(prog)s (default: %(default)s)') >>> parser.print_help() usage: frobble [-h] [bar] @@ -1230,7 +1230,7 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument('bar') - >>> parser.parse_args(['XXX']) + >>> parser.parse_args('XXX'.split()) Namespace(bar='XXX') For optional argument actions, the value of ``dest`` is normally inferred from @@ -1327,22 +1327,22 @@ >>> parser = argparse.ArgumentParser(prog='PROG') >>> parser.add_argument('-x') >>> parser.add_argument('--foo') - >>> parser.parse_args(['-x', 'X']) + >>> parser.parse_args('-x X'.split()) Namespace(foo=None, x='X') - >>> parser.parse_args(['--foo', 'FOO']) + >>> parser.parse_args('--foo FOO'.split()) Namespace(foo='FOO', x=None) For long options (options with names longer than a single character), the option and value can also be passed as a single command-line argument, using ``=`` to separate them:: - >>> parser.parse_args(['--foo=FOO']) + >>> parser.parse_args('--foo=FOO'.split()) Namespace(foo='FOO', x=None) For short options (options only one character long), the option and its value can be concatenated:: - >>> parser.parse_args(['-xX']) + >>> parser.parse_args('-xX'.split()) Namespace(foo=None, x='X') Several short options can be joined together, using only a single ``-`` prefix, @@ -1352,7 +1352,7 @@ >>> parser.add_argument('-x', action='store_true') >>> parser.add_argument('-y', action='store_true') >>> parser.add_argument('-z') - >>> parser.parse_args(['-xyzZ']) + >>> parser.parse_args('-xyzZ'.split()) Namespace(x=True, y=True, z='Z') @@ -1468,13 +1468,13 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument( ... 'integers', metavar='int', type=int, choices=range(10), - ... nargs='+', help='an integer in the range 0..9') + ... nargs='+', help='an integer in the range 0..9') >>> parser.add_argument( ... '--sum', dest='accumulate', action='store_const', const=sum, - ... default=max, help='sum the integers (default: find the max)') + ... default=max, help='sum the integers (default: find the max)') >>> parser.parse_args(['1', '2', '3', '4']) Namespace(accumulate=, integers=[1, 2, 3, 4]) - >>> parser.parse_args(['1', '2', '3', '4', '--sum']) + >>> parser.parse_args('1 2 3 4 --sum'.split()) Namespace(accumulate=, integers=[1, 2, 3, 4]) diff -r 3811995aad73 -r 34456cce64bb Doc/library/array.rst --- a/Doc/library/array.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/array.rst Thu May 19 13:47:42 2016 +0200 @@ -91,7 +91,7 @@ concatenation, and multiplication. When using slice assignment, the assigned value must be an array object with the same type code; in all other cases, :exc:`TypeError` is raised. Array objects also implement the buffer interface, -and may be used wherever :term:`bytes-like objects ` are supported. +and may be used wherever :term:`bytes-like object`\ s are supported. The following data items and methods are also supported: @@ -271,7 +271,7 @@ Packing and unpacking of External Data Representation (XDR) data as used in some remote procedure call systems. - `The Numerical Python Documentation `_ + `The Numerical Python Documentation `_ The Numeric Python extension (NumPy) defines another array type; see http://www.numpy.org/ for further information about Numerical Python. diff -r 3811995aad73 -r 34456cce64bb Doc/library/asynchat.rst --- a/Doc/library/asynchat.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/asynchat.rst Thu May 19 13:47:42 2016 +0200 @@ -57,13 +57,13 @@ The asynchronous output buffer size (default ``4096``). Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to - define a :abbr:`FIFO (first-in, first-out)` queue of *producers*. A producer need + define a first-in-first-out queue (fifo) of *producers*. A producer need have only one method, :meth:`more`, which should return data to be transmitted on the channel. The producer indicates exhaustion (*i.e.* that it contains no more data) by having its :meth:`more` method return the empty bytes object. At this point - the :class:`async_chat` object removes the producer from the queue and starts - using the next producer, if any. When the producer queue is empty the + the :class:`async_chat` object removes the producer from the fifo and starts + using the next producer, if any. When the producer fifo is empty the :meth:`handle_write` method does nothing. You use the channel object's :meth:`set_terminator` method to describe how to recognize the end of, or an important breakpoint in, an incoming transmission from the remote @@ -77,8 +77,8 @@ .. method:: async_chat.close_when_done() - Pushes a ``None`` on to the producer queue. When this producer is popped off - the queue it causes the channel to be closed. + Pushes a ``None`` on to the producer fifo. When this producer is popped off + the fifo it causes the channel to be closed. .. method:: async_chat.collect_incoming_data(data) @@ -91,7 +91,7 @@ .. method:: async_chat.discard_buffers() In emergencies this method will discard any data held in the input and/or - output buffers and the producer queue. + output buffers and the producer fifo. .. method:: async_chat.found_terminator() @@ -109,7 +109,7 @@ .. method:: async_chat.push(data) - Pushes data on to the channel's queue to ensure its transmission. + Pushes data on to the channel's fifo to ensure its transmission. This is all you need to do to have the channel write the data out to the network, although it is possible to use your own producers in more complex schemes to implement encryption and chunking, for example. @@ -117,7 +117,7 @@ .. method:: async_chat.push_with_producer(producer) - Takes a producer object and adds it to the producer queue associated with + Takes a producer object and adds it to the producer fifo associated with the channel. When all currently-pushed producers have been exhausted the channel will consume this producer's data by calling its :meth:`more` method and send the data to the remote endpoint. @@ -202,7 +202,7 @@ self.set_terminator(None) self.handle_request() elif not self.handling: - self.set_terminator(None) # browsers sometimes over-send + self.set_terminator(None) # browsers sometimes over-send self.cgi_data = parse(self.headers, b"".join(self.ibuffer)) self.handling = True self.ibuffer = [] diff -r 3811995aad73 -r 34456cce64bb Doc/library/asyncio-eventloop.rst --- a/Doc/library/asyncio-eventloop.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/asyncio-eventloop.rst Thu May 19 13:47:42 2016 +0200 @@ -101,9 +101,8 @@ called after :meth:`call_soon` returns, when control returns to the event loop. - This operates as a :abbr:`FIFO (first-in, first-out)` queue, callbacks - are called in the order in which they are registered. Each callback - will be called exactly once. + This operates as a FIFO queue, callbacks are called in the order in + which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. @@ -180,20 +179,6 @@ The :func:`asyncio.sleep` function. -Futures -------- - -.. method:: BaseEventLoop.create_future() - - Create an :class:`asyncio.Future` object attached to the loop. - - This is a preferred way to create futures in asyncio, as event - loop implementations can provide alternative implementations - of the Future class (with better performance or instrumentation). - - .. versionadded:: 3.5.2 - - Tasks ----- @@ -684,13 +669,6 @@ will be a ``dict`` object (see :meth:`call_exception_handler` documentation for details about context). -.. method:: BaseEventLoop.get_exception_handler() - - Return the exception handler, or ``None`` if the default one - is in use. - - .. versionadded:: 3.5.2 - .. method:: BaseEventLoop.default_exception_handler(context) Default exception handler. diff -r 3811995aad73 -r 34456cce64bb Doc/library/asyncio-stream.rst --- a/Doc/library/asyncio-stream.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/asyncio-stream.rst Thu May 19 13:47:42 2016 +0200 @@ -142,30 +142,6 @@ This method is a :ref:`coroutine `. - .. coroutinemethod:: readuntil(separator=b'\n') - - Read data from the stream until ``separator`` is found. - - On success, the data and separator will be removed from the - internal buffer (consumed). Returned data will include the - separator at the end. - - Configured stream limit is used to check result. Limit sets the - maximal length of data that can be returned, not counting the - separator. - - If an EOF occurs and the complete separator is still not found, - an :exc:`IncompleteReadError` exception will be - raised, and the internal buffer will be reset. The - :attr:`IncompleteReadError.partial` attribute may contain the - separator partially. - - If the data cannot be read because of over limit, a - :exc:`LimitOverrunError` exception will be raised, and the data - will be left in the internal buffer, so it can be read again. - - .. versionadded:: 3.5.2 - .. method:: at_eof() Return ``True`` if the buffer is empty and :meth:`feed_eof` was called. @@ -275,18 +251,6 @@ Read bytes string before the end of stream was reached (:class:`bytes`). -LimitOverrunError -================= - -.. exception:: LimitOverrunError - - Reached the buffer limit while looking for a separator. - - .. attribute:: consumed - - Total number of to be consumed bytes. - - Stream examples =============== diff -r 3811995aad73 -r 34456cce64bb Doc/library/asyncio-sync.rst --- a/Doc/library/asyncio-sync.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/asyncio-sync.rst Thu May 19 13:47:42 2016 +0200 @@ -71,14 +71,14 @@ lock = Lock() ... with (yield from lock): - ... + ... Lock objects can be tested for locking state:: if not lock.locked(): - yield from lock + yield from lock else: - # lock is acquired + # lock is acquired ... .. method:: locked() diff -r 3811995aad73 -r 34456cce64bb Doc/library/asyncio-task.rst --- a/Doc/library/asyncio-task.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/asyncio-task.rst Thu May 19 13:47:42 2016 +0200 @@ -677,8 +677,6 @@ Passing ``None`` as *timeout* argument disables the manager logic. - .. versionadded:: 3.5.2 - .. coroutinefunction:: wait(futures, \*, loop=None, timeout=None,\ return_when=ALL_COMPLETED) diff -r 3811995aad73 -r 34456cce64bb Doc/library/asyncore.rst --- a/Doc/library/asyncore.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/asyncore.rst Thu May 19 13:47:42 2016 +0200 @@ -315,8 +315,8 @@ self.buffer = self.buffer[sent:] - client = HTTPClient('www.python.org', '/') - asyncore.loop() + client = HTTPClient('www.python.org', '/') + asyncore.loop() .. _asyncore-example-2: diff -r 3811995aad73 -r 34456cce64bb Doc/library/audioop.rst --- a/Doc/library/audioop.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/audioop.rst Thu May 19 13:47:42 2016 +0200 @@ -7,7 +7,7 @@ The :mod:`audioop` module contains some useful operations on sound fragments. It operates on sound fragments consisting of signed integer samples 8, 16, 24 -or 32 bits wide, stored in :term:`bytes-like objects `. All scalar items are +or 32 bits wide, stored in :term:`bytes-like object`\ s. All scalar items are integers, unless specified otherwise. .. versionchanged:: 3.4 @@ -276,6 +276,6 @@ # out_test) prefill = '\0'*(pos+ipos)*2 postfill = '\0'*(len(inputdata)-len(prefill)-len(outputdata)) - outputdata = prefill + audioop.mul(outputdata, 2, -factor) + postfill + outputdata = prefill + audioop.mul(outputdata,2,-factor) + postfill return audioop.add(inputdata, outputdata, 2) diff -r 3811995aad73 -r 34456cce64bb Doc/library/base64.rst --- a/Doc/library/base64.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/base64.rst Thu May 19 13:47:42 2016 +0200 @@ -40,7 +40,7 @@ the modern interface. .. versionchanged:: 3.4 - Any :term:`bytes-like objects ` are now accepted by all + Any :term:`bytes-like object`\ s are now accepted by all encoding and decoding functions in this module. Ascii85/Base85 support added. The modern interface provides: diff -r 3811995aad73 -r 34456cce64bb Doc/library/binascii.rst --- a/Doc/library/binascii.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/binascii.rst Thu May 19 13:47:42 2016 +0200 @@ -21,7 +21,7 @@ .. note:: ``a2b_*`` functions accept Unicode strings containing only ASCII characters. - Other functions only accept :term:`bytes-like objects ` (such as + Other functions only accept :term:`bytes-like object`\ s (such as :class:`bytes`, :class:`bytearray` and other objects that support the buffer protocol). diff -r 3811995aad73 -r 34456cce64bb Doc/library/bisect.rst --- a/Doc/library/bisect.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/bisect.rst Thu May 19 13:47:42 2016 +0200 @@ -60,7 +60,7 @@ .. seealso:: `SortedCollection recipe - `_ that uses + `_ that uses bisect to build a full-featured collection class with straight-forward search methods and support for a key-function. The keys are precomputed to save unnecessary calls to the key function during searches. diff -r 3811995aad73 -r 34456cce64bb Doc/library/codecs.rst --- a/Doc/library/codecs.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/codecs.rst Thu May 19 13:47:42 2016 +0200 @@ -977,7 +977,7 @@ * an ISO 8859 codeset -* a Microsoft Windows code page, which is typically derived from an 8859 codeset, +* a Microsoft Windows code page, which is typically derived from a 8859 codeset, but replaces control characters with additional graphic characters * an IBM EBCDIC code page @@ -1414,7 +1414,7 @@ names (:mod:`http.client` then also transparently sends an IDNA hostname in the :mailheader:`Host` field if it sends that field at all). -.. _section 3.1: https://tools.ietf.org/html/rfc3490#section-3.1 +.. _section 3.1: http://tools.ietf.org/html/rfc3490#section-3.1 When receiving host names from the wire (such as in reverse name lookup), no automatic conversion to Unicode is performed: Applications wishing to present diff -r 3811995aad73 -r 34456cce64bb Doc/library/collections.abc.rst --- a/Doc/library/collections.abc.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/collections.abc.rst Thu May 19 13:47:42 2016 +0200 @@ -225,22 +225,19 @@ :meth:`isdisjoint`:: class ListBasedSet(collections.abc.Set): - ''' Alternate set implementation favoring space over speed - and not requiring the set elements to be hashable. ''' - def __init__(self, iterable): - self.elements = lst = [] - for value in iterable: - if value not in lst: - lst.append(value) - - def __iter__(self): - return iter(self.elements) - - def __contains__(self, value): - return value in self.elements - - def __len__(self): - return len(self.elements) + ''' Alternate set implementation favoring space over speed + and not requiring the set elements to be hashable. ''' + def __init__(self, iterable): + self.elements = lst = [] + for value in iterable: + if value not in lst: + lst.append(value) + def __iter__(self): + return iter(self.elements) + def __contains__(self, value): + return value in self.elements + def __len__(self): + return len(self.elements) s1 = ListBasedSet('abcdef') s2 = ListBasedSet('defghi') @@ -273,7 +270,7 @@ .. seealso:: - * `OrderedSet recipe `_ for an + * `OrderedSet recipe `_ for an example built on :class:`MutableSet`. * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. diff -r 3811995aad73 -r 34456cce64bb Doc/library/collections.rst --- a/Doc/library/collections.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/collections.rst Thu May 19 13:47:42 2016 +0200 @@ -116,12 +116,12 @@ :meth:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe - `_ has options to control + `_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap - `_. + `_. :class:`ChainMap` Examples and Recipes @@ -957,7 +957,7 @@ .. seealso:: * `Recipe for named tuple abstract base class with a metaclass mix-in - `_ + `_ by Jan Kaliszewski. Besides providing an :term:`abstract base class` for named tuples, it also supports an alternate :term:`metaclass`-based constructor that is convenient for use cases where named tuples are being @@ -987,9 +987,8 @@ .. method:: popitem(last=True) The :meth:`popitem` method for ordered dictionaries returns and removes a - (key, value) pair. The pairs are returned in - :abbr:`LIFO (last-in, first-out)` order if *last* is true - or :abbr:`FIFO (first-in, first-out)` order if false. + (key, value) pair. The pairs are returned in LIFO order if *last* is true + or FIFO order if false. .. method:: move_to_end(key, last=True) @@ -1033,7 +1032,7 @@ in conjunction with sorting to make a sorted dictionary:: >>> # regular unsorted dictionary - >>> d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2} + >>> d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2} >>> # dictionary sorted by key >>> OrderedDict(sorted(d.items(), key=lambda t: t[0])) diff -r 3811995aad73 -r 34456cce64bb Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/colorsys.rst Thu May 19 13:47:42 2016 +0200 @@ -21,7 +21,7 @@ More information about color spaces can be found at http://www.poynton.com/ColorFAQ.html and - https://www.cambridgeincolour.com/tutorials/color-spaces.htm. + http://www.cambridgeincolour.com/tutorials/color-spaces.htm. The :mod:`colorsys` module defines the following functions: diff -r 3811995aad73 -r 34456cce64bb Doc/library/concurrent.futures.rst --- a/Doc/library/concurrent.futures.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/concurrent.futures.rst Thu May 19 13:47:42 2016 +0200 @@ -99,12 +99,12 @@ import time def wait_on_b(): time.sleep(5) - print(b.result()) # b will never complete because it is waiting on a. + print(b.result()) # b will never complete because it is waiting on a. return 5 def wait_on_a(): time.sleep(5) - print(a.result()) # a will never complete because it is waiting on b. + print(a.result()) # a will never complete because it is waiting on b. return 6 diff -r 3811995aad73 -r 34456cce64bb Doc/library/configparser.rst --- a/Doc/library/configparser.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/configparser.rst Thu May 19 13:47:42 2016 +0200 @@ -833,13 +833,13 @@ # Set the optional *raw* argument of get() to True if you wish to disable # interpolation in a single get operation. - print(cfg.get('Section1', 'foo', raw=False)) # -> "Python is fun!" - print(cfg.get('Section1', 'foo', raw=True)) # -> "%(bar)s is %(baz)s!" + print(cfg.get('Section1', 'foo', raw=False)) # -> "Python is fun!" + print(cfg.get('Section1', 'foo', raw=True)) # -> "%(bar)s is %(baz)s!" # The optional *vars* argument is a dict with members that will take # precedence in interpolation. print(cfg.get('Section1', 'foo', vars={'bar': 'Documentation', - 'baz': 'evil'})) + 'baz': 'evil'})) # The optional *fallback* argument can be used to provide a fallback value print(cfg.get('Section1', 'foo')) @@ -866,10 +866,10 @@ config = configparser.ConfigParser({'bar': 'Life', 'baz': 'hard'}) config.read('example.cfg') - print(config.get('Section1', 'foo')) # -> "Python is fun!" + print(config.get('Section1', 'foo')) # -> "Python is fun!" config.remove_option('Section1', 'bar') config.remove_option('Section1', 'baz') - print(config.get('Section1', 'foo')) # -> "Life is hard!" + print(config.get('Section1', 'foo')) # -> "Life is hard!" .. _configparser-objects: diff -r 3811995aad73 -r 34456cce64bb Doc/library/contextlib.rst --- a/Doc/library/contextlib.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/contextlib.rst Thu May 19 13:47:42 2016 +0200 @@ -656,7 +656,7 @@ Before After >>> with cm: - ... pass + ... pass ... Traceback (most recent call last): ... diff -r 3811995aad73 -r 34456cce64bb Doc/library/crypt.rst --- a/Doc/library/crypt.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/crypt.rst Thu May 19 13:47:42 2016 +0200 @@ -149,4 +149,4 @@ hashed = crypt.crypt(plaintext) if not compare_hash(hashed, crypt.crypt(plaintext, hashed)): - raise ValueError("hashed version doesn't validate against original") + raise ValueError("hashed version doesn't validate against original") diff -r 3811995aad73 -r 34456cce64bb Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/ctypes.rst Thu May 19 13:47:42 2016 +0200 @@ -52,11 +52,11 @@ convention:: >>> from ctypes import * - >>> print(windll.kernel32) # doctest: +WINDOWS + >>> print(windll.kernel32) # doctest: +WINDOWS - >>> print(cdll.msvcrt) # doctest: +WINDOWS + >>> print(cdll.msvcrt) # doctest: +WINDOWS - >>> libc = cdll.msvcrt # doctest: +WINDOWS + >>> libc = cdll.msvcrt # doctest: +WINDOWS >>> Windows appends the usual ``.dll`` file suffix automatically. @@ -72,10 +72,10 @@ :meth:`LoadLibrary` method of the dll loaders should be used, or you should load the library by creating an instance of CDLL by calling the constructor:: - >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX + >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX - >>> libc = CDLL("libc.so.6") # doctest: +LINUX - >>> libc # doctest: +LINUX + >>> libc = CDLL("libc.so.6") # doctest: +LINUX + >>> libc # doctest: +LINUX >>> @@ -92,9 +92,9 @@ >>> from ctypes import * >>> libc.printf <_FuncPtr object at 0x...> - >>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS + >>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS <_FuncPtr object at 0x...> - >>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS + >>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? File "ctypes.py", line 239, in __getattr__ @@ -123,16 +123,16 @@ identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use :func:`getattr` to retrieve the function:: - >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS + >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS <_FuncPtr object at 0x...> >>> On Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ordinal number:: - >>> cdll.kernel32[1] # doctest: +WINDOWS + >>> cdll.kernel32[1] # doctest: +WINDOWS <_FuncPtr object at 0x...> - >>> cdll.kernel32[0] # doctest: +WINDOWS + >>> cdll.kernel32[0] # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? File "ctypes.py", line 310, in __getitem__ @@ -154,9 +154,9 @@ This example calls both functions with a NULL pointer (``None`` should be used as the NULL pointer):: - >>> print(libc.time(None)) # doctest: +SKIP + >>> print(libc.time(None)) # doctest: +SKIP 1150640792 - >>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS + >>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS 0x1d000000 >>> @@ -165,11 +165,11 @@ Windows. It does this by examining the stack after the function returns, so although an error is raised the function *has* been called:: - >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS + >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with not enough arguments (4 bytes missing) - >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS + >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with too many arguments (4 bytes in excess) @@ -178,13 +178,13 @@ The same exception is raised when you call an ``stdcall`` function with the ``cdecl`` calling convention, or vice versa:: - >>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS + >>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with not enough arguments (4 bytes missing) >>> - >>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS + >>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with too many arguments (4 bytes in excess) @@ -197,7 +197,7 @@ crashes from general protection faults when functions are called with invalid argument values:: - >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS + >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? OSError: exception: access violation reading 0x00000020 @@ -462,9 +462,9 @@ a string pointer and a char, and returns a pointer to a string:: >>> strchr = libc.strchr - >>> strchr(b"abcdef", ord("d")) # doctest: +SKIP + >>> strchr(b"abcdef", ord("d")) # doctest: +SKIP 8059983 - >>> strchr.restype = c_char_p # c_char_p is a pointer to a string + >>> strchr.restype = c_char_p # c_char_p is a pointer to a string >>> strchr(b"abcdef", ord("d")) b'def' >>> print(strchr(b"abcdef", ord("x"))) @@ -495,17 +495,17 @@ result of this call will be used as the result of your function call. This is useful to check for error return values and automatically raise an exception:: - >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS + >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS >>> def ValidHandle(value): ... if value == 0: ... raise WinError() ... return value ... >>> - >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS - >>> GetModuleHandle(None) # doctest: +WINDOWS + >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS + >>> GetModuleHandle(None) # doctest: +WINDOWS 486539264 - >>> GetModuleHandle("something silly") # doctest: +WINDOWS + >>> GetModuleHandle("something silly") # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? File "", line 3, in ValidHandle @@ -676,12 +676,12 @@ >>> from ctypes import * >>> class POINT(Structure): - ... _fields_ = ("x", c_int), ("y", c_int) + ... _fields_ = ("x", c_int), ("y", c_int) ... >>> class MyStruct(Structure): - ... _fields_ = [("a", c_int), - ... ("b", c_float), - ... ("point_array", POINT * 4)] + ... _fields_ = [("a", c_int), + ... ("b", c_float), + ... ("point_array", POINT * 4)] >>> >>> print(len(MyStruct().point_array)) 4 @@ -998,7 +998,7 @@ The result:: - >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX + >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX py_cmp_func 5 1 py_cmp_func 33 99 py_cmp_func 7 33 @@ -1100,15 +1100,14 @@ hit the NULL entry:: >>> for item in table: - ... if item.name is None: - ... break - ... print(item.name.decode("ascii"), item.size) + ... print(item.name, item.size) + ... if item.name is None: + ... break ... - _frozen_importlib 31764 - _frozen_importlib_external 41499 - __hello__ 161 - __phello__ -161 - __phello__.spam 161 + __hello__ 104 + __phello__ -104 + __phello__.spam 104 + None 0 >>> The fact that standard Python has a frozen module and a frozen package diff -r 3811995aad73 -r 34456cce64bb Doc/library/datetime.rst --- a/Doc/library/datetime.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/datetime.rst Thu May 19 13:47:42 2016 +0200 @@ -562,7 +562,7 @@ Return a 3-tuple, (ISO year, ISO week number, ISO weekday). The ISO calendar is a widely used variant of the Gregorian calendar. See - https://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good + http://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good explanation. The ISO year consists of 52 or 53 full weeks, and where a week starts on a @@ -1775,7 +1775,7 @@ *pytz* library brings the *IANA timezone database* (also known as the Olson database) to Python and its usage is recommended. - `IANA timezone database `_ + `IANA timezone database `_ The Time Zone Database (often called tz or zoneinfo) contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes @@ -1941,7 +1941,7 @@ +-----------+--------------------------------+------------------------+-------+ | ``%z`` | UTC offset in the form +HHMM | (empty), +0000, -0400, | \(6) | | | or -HHMM (empty string if the | +1030 | | -| | object is naive). | | | +| | the object is naive). | | | +-----------+--------------------------------+------------------------+-------+ | ``%Z`` | Time zone name (empty string | (empty), UTC, EST, CST | | | | if the object is naive). | | | diff -r 3811995aad73 -r 34456cce64bb Doc/library/difflib.rst --- a/Doc/library/difflib.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/difflib.rst Thu May 19 13:47:42 2016 +0200 @@ -613,7 +613,7 @@ work. * `Simple version control recipe - `_ for a small application + `_ for a small application built with :class:`SequenceMatcher`. diff -r 3811995aad73 -r 34456cce64bb Doc/library/dis.rst --- a/Doc/library/dis.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/dis.rst Thu May 19 13:47:42 2016 +0200 @@ -139,11 +139,11 @@ Disassemble the *x* object. *x* can denote either a module, a class, a method, a function, a generator, a code object, a string of source code or a byte sequence of raw bytecode. For a module, it disassembles all functions. - For a class, it disassembles all methods (including class and static methods). - For a code object or sequence of raw bytecode, it prints one line per bytecode - instruction. Strings are first compiled to code objects with the :func:`compile` - built-in function before being disassembled. If no object is provided, this - function disassembles the last traceback. + For a class, it disassembles all methods. For a code object or sequence of + raw bytecode, it prints one line per bytecode instruction. Strings are first + compiled to code objects with the :func:`compile` built-in function before being + disassembled. If no object is provided, this function disassembles the last + traceback. The disassembly is written as text to the supplied *file* argument if provided and to ``sys.stdout`` otherwise. diff -r 3811995aad73 -r 34456cce64bb Doc/library/email.headerregistry.rst --- a/Doc/library/email.headerregistry.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/email.headerregistry.rst Thu May 19 13:47:42 2016 +0200 @@ -171,7 +171,7 @@ :class:`~datetime.datetime` instance. This means, for example, that the following code is valid and does what one would expect:: - msg['Date'] = datetime(2011, 7, 15, 21) + msg['Date'] = datetime(2011, 7, 15, 21) Because this is a naive ``datetime`` it will be interpreted as a UTC timestamp, and the resulting value will have a timezone of ``-0000``. Much diff -r 3811995aad73 -r 34456cce64bb Doc/library/fileinput.rst --- a/Doc/library/fileinput.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/fileinput.rst Thu May 19 13:47:42 2016 +0200 @@ -193,14 +193,10 @@ Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_compressed)`` -.. function:: hook_encoded(encoding, errors=None) +.. function:: hook_encoded(encoding) - Returns a hook which opens each file with :func:`open`, using the given - *encoding* and *errors* to read the file. + Returns a hook which opens each file with :func:`codecs.open`, using the given + *encoding* to read the file. Usage example: ``fi = - fileinput.FileInput(openhook=fileinput.hook_encoded("utf-8", - "surrogateescape"))`` - - .. versionchanged:: 3.6 - Added the optional *errors* parameter. + fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))`` diff -r 3811995aad73 -r 34456cce64bb Doc/library/getopt.rst --- a/Doc/library/getopt.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/getopt.rst Thu May 19 13:47:42 2016 +0200 @@ -124,7 +124,7 @@ opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) except getopt.GetoptError as err: # print help information and exit: - print(err) # will print something like "option -a not recognized" + print(err) # will print something like "option -a not recognized" usage() sys.exit(2) output = None diff -r 3811995aad73 -r 34456cce64bb Doc/library/hashlib.rst --- a/Doc/library/hashlib.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/hashlib.rst Thu May 19 13:47:42 2016 +0200 @@ -41,7 +41,7 @@ There is one constructor method named for each type of :dfn:`hash`. All return a hash object with the same simple interface. For example: use :func:`sha1` to create a SHA1 hash object. You can now feed this object with :term:`bytes-like -objects ` (normally :class:`bytes`) using the :meth:`update` method. +object`\ s (normally :class:`bytes`) using the :meth:`update` method. At any point you can ask it for the :dfn:`digest` of the concatenation of the data fed to it so far using the :meth:`digest` or :meth:`hexdigest` methods. @@ -232,5 +232,5 @@ Wikipedia article with information on which algorithms have known issues and what that means regarding their use. - https://www.ietf.org/rfc/rfc2898.txt + http://www.ietf.org/rfc/rfc2898.txt PKCS #5: Password-Based Cryptography Specification Version 2.0 diff -r 3811995aad73 -r 34456cce64bb Doc/library/html.entities.rst --- a/Doc/library/html.entities.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/html.entities.rst Thu May 19 13:47:42 2016 +0200 @@ -43,4 +43,4 @@ .. rubric:: Footnotes -.. [#] See https://www.w3.org/TR/html5/syntax.html#named-character-references +.. [#] See http://www.w3.org/TR/html5/syntax.html#named-character-references diff -r 3811995aad73 -r 34456cce64bb Doc/library/html.parser.rst --- a/Doc/library/html.parser.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/html.parser.rst Thu May 19 13:47:42 2016 +0200 @@ -51,10 +51,8 @@ class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Encountered a start tag:", tag) - def handle_endtag(self, tag): print("Encountered an end tag :", tag) - def handle_data(self, data): print("Encountered some data :", data) @@ -133,8 +131,8 @@ and quotes in the *value* have been removed, and character and entity references have been replaced. - For instance, for the tag ````, this method - would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``. + For instance, for the tag ````, this method + would be called as ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``. All entity references from :mod:`html.entities` are replaced in the attribute values. @@ -239,27 +237,21 @@ print("Start tag:", tag) for attr in attrs: print(" attr:", attr) - def handle_endtag(self, tag): print("End tag :", tag) - def handle_data(self, data): print("Data :", data) - def handle_comment(self, data): print("Comment :", data) - def handle_entityref(self, name): c = chr(name2codepoint[name]) print("Named ent:", c) - def handle_charref(self, name): if name.startswith('x'): c = chr(int(name[1:], 16)) else: c = chr(int(name)) print("Num ent :", c) - def handle_decl(self, data): print("Decl :", data) @@ -291,7 +283,7 @@ attr: ('type', 'text/css') Data : #python { color: green } End tag : style - + >>> >>> parser.feed('') Start tag: script diff -r 3811995aad73 -r 34456cce64bb Doc/library/http.client.rst --- a/Doc/library/http.client.rst Wed May 18 15:54:24 2016 -0700 +++ b/Doc/library/http.client.rst Thu May 19 13:47:42 2016 +0200 @@ -441,7 +441,7 @@ >>> conn.request("GET", "/") >>> r1 = conn.getresponse() >>> while not r1.closed: - ... print(r1.read(200)) # 200 bytes + ... print(r1.read(200)) # 200 bytes b'\n diff -r 3811995aad73 -r 34456cce64bb Tools/msi/launcher/launcher.wixproj --- a/Tools/msi/launcher/launcher.wixproj Wed May 18 15:54:24 2016 -0700 +++ b/Tools/msi/launcher/launcher.wixproj Thu May 19 13:47:42 2016 +0200 @@ -5,8 +5,7 @@ 2.0 launcher Package - UpgradeCode=1B68A0EC-4DD3-5134-840E-73854B0863F1;$(DefineConstants) - true + SkipMissingCore=1;$(DefineConstants) diff -r 3811995aad73 -r 34456cce64bb Tools/msi/launcher/launcher.wxs --- a/Tools/msi/launcher/launcher.wxs Wed May 18 15:54:24 2016 -0700 +++ b/Tools/msi/launcher/launcher.wxs Thu May 19 13:47:42 2016 +0200 @@ -5,6 +5,7 @@ + @@ -26,18 +27,12 @@ NOT Installed AND NOT ALLUSERS=1 NOT Installed AND ALLUSERS=1 - UPGRADE or REMOVE_350_LAUNCHER + UPGRADE or REMOVE_OLD_LAUNCHER - + - + - - - - - - Installed OR NOT BLOCK_360A1_LAUNCHER diff -r 3811995aad73 -r 34456cce64bb Tools/msi/launcher/launcher_en-US.wxl --- a/Tools/msi/launcher/launcher_en-US.wxl Wed May 18 15:54:24 2016 -0700 +++ b/Tools/msi/launcher/launcher_en-US.wxl Thu May 19 13:47:42 2016 +0200 @@ -1,13 +1,7 @@  - 1033 - en-us - Python Launcher - Python Launcher - Python Launcher - Python Software Foundation - A newer version of the Python launcher is already installed. - The TARGETDIR variable must be provided when invoking this installer. + Launcher + launcher Python File Python File (no console) Compiled Python File diff -r 3811995aad73 -r 34456cce64bb Tools/msi/msi.props --- a/Tools/msi/msi.props Wed May 18 15:54:24 2016 -0700 +++ b/Tools/msi/msi.props Thu May 19 13:47:42 2016 +0200 @@ -39,7 +39,7 @@ - + WixUtilExtension WixUtilExtension @@ -150,7 +150,7 @@ lib2to3/pickles - + <_Uuids>@(_Uuid->'("%(Identity)", "$(MajorVersionNumber).$(MinorVersionNumber)/%(Uri)")',',') <_GenerateCommand>import uuid; print('\n'.join('{}={}'.format(i, uuid.uuid5(uuid.UUID('c8d9733e-a70c-43ff-ab0c-e26456f11083'), '$(ReleaseUri.Replace(`{arch}`, `$(ArchName)`))' + j)) for i,j in [$(_Uuids.Replace(`"`,`'`))])) diff -r 3811995aad73 -r 34456cce64bb Tools/msi/msi.targets --- a/Tools/msi/msi.targets Wed May 18 15:54:24 2016 -0700 +++ b/Tools/msi/msi.targets Thu May 19 13:47:42 2016 +0200 @@ -25,7 +25,7 @@ - + <_Content>$([System.IO.File]::ReadAllText(%(WxlTemplate.FullPath)).Replace(`{{ShortVersion}}`, `$(MajorVersionNumber).$(MinorVersionNumber)$(PyTestExt)`).Replace(`{{LongVersion}}`, `$(PythonVersion)$(PyTestExt)`).Replace(`{{Bitness}}`, `$(Bitness)`)) <_ExistingContent Condition="Exists('$(IntermediateOutputPath)%(WxlTemplate.Filename).wxl')">$([System.IO.File]::ReadAllText($(IntermediateOutputPath)%(WxlTemplate.Filename).wxl)) @@ -35,7 +35,7 @@ Overwrite="true" Condition="$(_Content) != $(_ExistingContent)" /> - + diff -r 3811995aad73 -r 34456cce64bb Tools/scripts/diff.py --- a/Tools/scripts/diff.py Wed May 18 15:54:24 2016 -0700 +++ b/Tools/scripts/diff.py Thu May 19 13:47:42 2016 +0200 @@ -8,7 +8,7 @@ """ -import sys, os, difflib, argparse +import sys, os, time, difflib, argparse from datetime import datetime, timezone def file_mtime(path): diff -r 3811995aad73 -r 34456cce64bb configure --- a/configure Wed May 18 15:54:24 2016 -0700 +++ b/configure Thu May 19 13:47:42 2016 +0200 @@ -751,7 +751,6 @@ build_vendor build_cpu build -cross_compiling HAS_HG HGBRANCH HGTAG @@ -12918,33 +12917,6 @@ fi -ac_fn_c_check_member "$LINENO" "struct passwd" "pw_gecos" "ac_cv_member_struct_passwd_pw_gecos" " - #include - #include - -" -if test "x$ac_cv_member_struct_passwd_pw_gecos" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_PASSWD_PW_GECOS 1 -_ACEOF - - -fi -ac_fn_c_check_member "$LINENO" "struct passwd" "pw_passwd" "ac_cv_member_struct_passwd_pw_passwd" " - #include - #include - -" -if test "x$ac_cv_member_struct_passwd_pw_passwd" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_PASSWD_PW_PASSWD 1 -_ACEOF - - -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for time.h that defines altzone" >&5 $as_echo_n "checking for time.h that defines altzone... " >&6; } @@ -14255,85 +14227,6 @@ fi -ac_fn_c_check_decl "$LINENO" "RTLD_LAZY" "ac_cv_have_decl_RTLD_LAZY" "#include -" -if test "x$ac_cv_have_decl_RTLD_LAZY" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_LAZY $ac_have_decl -_ACEOF -ac_fn_c_check_decl "$LINENO" "RTLD_NOW" "ac_cv_have_decl_RTLD_NOW" "#include -" -if test "x$ac_cv_have_decl_RTLD_NOW" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_NOW $ac_have_decl -_ACEOF -ac_fn_c_check_decl "$LINENO" "RTLD_GLOBAL" "ac_cv_have_decl_RTLD_GLOBAL" "#include -" -if test "x$ac_cv_have_decl_RTLD_GLOBAL" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_GLOBAL $ac_have_decl -_ACEOF -ac_fn_c_check_decl "$LINENO" "RTLD_LOCAL" "ac_cv_have_decl_RTLD_LOCAL" "#include -" -if test "x$ac_cv_have_decl_RTLD_LOCAL" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_LOCAL $ac_have_decl -_ACEOF -ac_fn_c_check_decl "$LINENO" "RTLD_NODELETE" "ac_cv_have_decl_RTLD_NODELETE" "#include -" -if test "x$ac_cv_have_decl_RTLD_NODELETE" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_NODELETE $ac_have_decl -_ACEOF -ac_fn_c_check_decl "$LINENO" "RTLD_NOLOAD" "ac_cv_have_decl_RTLD_NOLOAD" "#include -" -if test "x$ac_cv_have_decl_RTLD_NOLOAD" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_NOLOAD $ac_have_decl -_ACEOF -ac_fn_c_check_decl "$LINENO" "RTLD_DEEPBIND" "ac_cv_have_decl_RTLD_DEEPBIND" "#include -" -if test "x$ac_cv_have_decl_RTLD_DEEPBIND" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RTLD_DEEPBIND $ac_have_decl -_ACEOF - - # determine what size digit to use for Python's longs { $as_echo "$as_me:${as_lineno-$LINENO}: checking digit size for Python's longs" >&5 $as_echo_n "checking digit size for Python's longs... " >&6; } diff -r 3811995aad73 -r 34456cce64bb configure.ac --- a/configure.ac Wed May 18 15:54:24 2016 -0700 +++ b/configure.ac Thu May 19 13:47:42 2016 +0200 @@ -49,7 +49,6 @@ AC_CONFIG_SRCDIR([Include/object.h]) AC_CONFIG_HEADER(pyconfig.h) -AC_SUBST(cross_compiling) AC_CANONICAL_HOST AC_SUBST(build) AC_SUBST(host) @@ -3762,10 +3761,6 @@ AC_CHECK_MEMBERS([struct stat.st_gen]) AC_CHECK_MEMBERS([struct stat.st_birthtime]) AC_CHECK_MEMBERS([struct stat.st_blocks]) -AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[ - #include - #include -]]) AC_MSG_CHECKING(for time.h that defines altzone) AC_CACHE_VAL(ac_cv_header_time_altzone,[ @@ -4342,8 +4337,6 @@ [define to 1 if your sem_getvalue is broken.]) fi -AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND], [], [], [[#include ]]) - # determine what size digit to use for Python's longs AC_MSG_CHECKING([digit size for Python's longs]) AC_ARG_ENABLE(big-digits, diff -r 3811995aad73 -r 34456cce64bb counters.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/counters.patch Thu May 19 13:47:42 2016 +0200 @@ -0,0 +1,74 @@ +diff -r 5a06b0e777ec Objects/dictobject.c +--- a/Objects/dictobject.c Fri Apr 29 10:48:08 2016 +0200 ++++ b/Objects/dictobject.c Fri Apr 29 10:48:43 2016 +0200 +@@ -216,6 +216,8 @@ static int dictresize(PyDictObject *mp, + static PyDictObject *free_list[PyDict_MAXFREELIST]; + static int numfree = 0; + ++Py_ssize_t _Py_dict_new = 0; ++ + #include "clinic/dictobject.c.h" + + int +@@ -383,6 +385,7 @@ new_dict(PyDictKeysObject *keys, PyObjec + mp->ma_keys = keys; + mp->ma_values = values; + mp->ma_used = 0; ++_Py_dict_new++; + return (PyObject *)mp; + } + +@@ -2723,6 +2726,7 @@ dict_new(PyTypeObject *type, PyObject *a + Py_DECREF(self); + return NULL; + } ++_Py_dict_new++; + return self; + } + +diff -r 5a06b0e777ec Objects/tupleobject.c +--- a/Objects/tupleobject.c Fri Apr 29 10:48:08 2016 +0200 ++++ b/Objects/tupleobject.c Fri Apr 29 10:48:43 2016 +0200 +@@ -4,6 +4,8 @@ + #include "Python.h" + #include "accu.h" + ++Py_ssize_t _Py_tuple_new = 0; ++ + /* Speed optimization to avoid frequent malloc/free of small tuples */ + #ifndef PyTuple_MAXSAVESIZE + #define PyTuple_MAXSAVESIZE 20 /* Largest tuple to save on free list */ +@@ -71,6 +73,9 @@ PyTuple_New(Py_ssize_t size) + PyErr_BadInternalCall(); + return NULL; + } ++ ++_Py_tuple_new++; ++ + #if PyTuple_MAXSAVESIZE > 0 + if (size == 0 && free_list[0]) { + op = free_list[0]; +diff -r 5a06b0e777ec Python/pylifecycle.c +--- a/Python/pylifecycle.c Fri Apr 29 10:48:08 2016 +0200 ++++ b/Python/pylifecycle.c Fri Apr 29 10:48:43 2016 +0200 +@@ -522,6 +522,9 @@ flush_std_files(void) + + */ + ++extern Py_ssize_t _Py_tuple_new; ++extern Py_ssize_t _Py_dict_new; ++ + int + Py_FinalizeEx(void) + { +@@ -712,6 +715,10 @@ Py_FinalizeEx(void) + #endif + + call_ll_exitfuncs(); ++ ++printf("tuple creation# %zd\n", _Py_tuple_new ); ++printf("dict creation# %zd\n", _Py_dict_new ); ++ + return status; + } + diff -r 3811995aad73 -r 34456cce64bb diff.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/diff.sh Thu May 19 13:47:42 2016 +0200 @@ -0,0 +1,1 @@ +hg diff -r 496e094f4734:tip "$@" diff -r 3811995aad73 -r 34456cce64bb notes.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/notes.txt Thu May 19 13:47:42 2016 +0200 @@ -0,0 +1,136 @@ +perf.py result at rev bf9be239c840 +================================== + +slower +------ + +* unpickle_list: 6% slower +* fastunpickle: 4% slower +* unpack_sequence: 5% slower, timing ~47 us, need to fix benchmark? +* pickle_list: 5% slower +* nbody: 6% slower -- very few function calls, pure Python + + - float-float, float*float, float += float, float -= float + + +perf.py result at rev 6c3a7b456304 +================================== + +Revision 6c3a7b456304, with ASLR, 50 processes. + +slower +------ + +10: + +* pidigits: 1.36x slower +* raytrace: 1.13x slower +* regex_effbot: 1.10x slower +* unpickle_list: 1.09x slower +* chaos: 1.08x slower +* fastunpickle: 1.04x slower +* unpack_sequence: 1.03x slower +* pickle_list: 1.03x slower +* nbody: 1.02x slower +* regex_v8: 1.02x slower + + +faster +------ + +15: + +* etree_iterparse: 1.15x faster ### +* pathlib: 1.09x faster +* silent_logging: 1.09x faster +* mako_v2: 1.06x faster +* call_method_unknown: 1.06x faster +* etree_parse: 1.05x faster +* etree_process: 1.05x faster +* etree_generate: 1.05x faster +* django_v3: 1.05x faster +* call_method: 1.03x faster +* call_simple: 1.03x faster +* richards: 1.03x faster +* regex_compile: 1.04x faster +* spectral_norm: 1.02x faster +* telco: 1.02x faster + +not significant, noise +---------------------- + +18: + +* 2to3 +* call_method_slots +* chameleon_v2 +* fannkuch +* fastpickle +* float +* formatted_logging +* go +* hexiom2 +* json_dump_v2 +* json_load +* meteor_contest +* normal_startup +* nqueens +* pickle_dict +* simple_logging +* startup_nosite +* tornado_http + + +Notes +===== + +ext_do_call(): func(*args, **kw) + Code: result = func(*args, **kwds) + Python scope: args=sequence (tuple), kw=mapping (dict) + + +Slow path +========= + +* _PyStack_AsTuple + +Optimized +========= + +* namedtuple .... get attribute +* object.__setattr__(obj, attr, value) +* wrapperdescr_fastcall: _socket.socket.__init__(...) + + +Not optimized (yet?) +==================== + +type_call() is not modified, it would require to modify + tp_new + tp_init + => duplicated methods, how inheritance is handled? + + +Benchmarks +========== + +default/python -m timeit -s 'class Bytes:' -s ' def __bytes__(self): return b"abc"' -s 'b = Bytes()' 'bytes(b)' +1000000 loops, best of 3: 0.249 usec per loop +=> best of 3: 0.227 usec per loop (-8%) + +default/python -m timeit -r 11 -s "from collections import namedtuple as n; a = n('n', 'a b c')(1, 2, 3)" -- "a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a; a.a" +1000000 loops, best of 11: 0.965 usec per loop +=> best of 11: 0.718 usec per loop (-25%) + +default/python -m timeit -s 'import types; set=object.__setattr__; obj=types.SimpleNamespace()' 'set(obj, "x", 1)' +10000000 loops, best of 3: 0.163 usec per loop +=> best of 3: 0.0967 usec per loop (-40%) + +default/python -m timeit -s 'import types; get=object.__getattribute__; obj=types.SimpleNamespace(); obj.x=1' 'get(obj, "x")' +10000000 loops, best of 3: 0.144 usec per loop +=> best of 3: 0.113 usec per loop (-20%) +=> best of 3: 0.0858 usec per loop (-40%) + +taskset_isolated.py default/python -m timeit 'getattr(1, "real")' +10000000 loops, best of 3: 0.0955 usec per loop +=> best of 3: 0.0656 usec per loop (-31%) diff -r 3811995aad73 -r 34456cce64bb pyconfig.h.in --- a/pyconfig.h.in Wed May 18 15:54:24 2016 -0700 +++ b/pyconfig.h.in Thu May 19 13:47:42 2016 +0200 @@ -167,34 +167,6 @@ */ #undef HAVE_DECL_ISNAN -/* Define to 1 if you have the declaration of `RTLD_DEEPBIND', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_DEEPBIND - -/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_GLOBAL - -/* Define to 1 if you have the declaration of `RTLD_LAZY', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_LAZY - -/* Define to 1 if you have the declaration of `RTLD_LOCAL', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_LOCAL - -/* Define to 1 if you have the declaration of `RTLD_NODELETE', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_NODELETE - -/* Define to 1 if you have the declaration of `RTLD_NOLOAD', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_NOLOAD - -/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you - don't. */ -#undef HAVE_DECL_RTLD_NOW - /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #undef HAVE_DECL_TZNAME @@ -944,12 +916,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STROPTS_H -/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */ -#undef HAVE_STRUCT_PASSWD_PW_GECOS - -/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */ -#undef HAVE_STRUCT_PASSWD_PW_PASSWD - /* Define to 1 if `st_birthtime' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BIRTHTIME diff -r 3811995aad73 -r 34456cce64bb regen_clinic.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regen_clinic.sh Thu May 19 13:47:42 2016 +0200 @@ -0,0 +1,6 @@ +set -e +for cfile in $(grep -l -F '[clinic' $(find -name "*.c")); do + echo "regen $cfile" + dbg/python Tools/clinic/clinic.py $cfile + touch $cfile +done diff -r 3811995aad73 -r 34456cce64bb setup.py --- a/setup.py Wed May 18 15:54:24 2016 -0700 +++ b/setup.py Thu May 19 13:47:42 2016 +0200 @@ -2060,7 +2060,7 @@ '_decimal/libmpdec/fnt.h', '_decimal/libmpdec/fourstep.h', '_decimal/libmpdec/io.h', - '_decimal/libmpdec/mpalloc.h', + '_decimal/libmpdec/memory.h', '_decimal/libmpdec/mpdecimal.h', '_decimal/libmpdec/numbertheory.h', '_decimal/libmpdec/sixstep.h',