Commit d56b5f84 authored by Raymond Hettinger's avatar Raymond Hettinger

Optimization notes.

parent 21f93aa3
...@@ -348,6 +348,11 @@ Some smaller changes made to the core Python language are: ...@@ -348,6 +348,11 @@ Some smaller changes made to the core Python language are:
the context manager protocol. This allows timely release of any resources the context manager protocol. This allows timely release of any resources
that were acquired when requesting a buffer from the original object. that were acquired when requesting a buffer from the original object.
>>> with memoryview(b'abcdefgh') as v:
... print(v.tolist())
...
[97, 98, 99, 100, 101, 102, 103, 104]
(Added by Antoine Pitrou; :issue:`9757`.) (Added by Antoine Pitrou; :issue:`9757`.)
* Mark Dickinson crafted an elegant and efficient scheme for assuring that * Mark Dickinson crafted an elegant and efficient scheme for assuring that
...@@ -389,13 +394,11 @@ Some smaller changes made to the core Python language are: ...@@ -389,13 +394,11 @@ Some smaller changes made to the core Python language are:
can be enabled through the means provided by the :mod:`warnings` can be enabled through the means provided by the :mod:`warnings`
module, or on the command line. module, or on the command line.
:exc:`ResourceWarning` is issued at interpreter shutdown if the A :exc:`ResourceWarning` is issued at interpreter shutdown if the
:data:`gc.garbage` list isn't empty. This is meant to make the programmer :data:`gc.garbage` list isn't empty. This is meant to make the programmer
aware that their code contains object finalization issues. aware that their code contains object finalization issues.
(Added by Antoine Pitrou and Georg Brandl; :issue:`477863`.) A :exc:`ResourceWarning` is also issued when a :term:`file object` is destroyed
:exc:`ResourceWarning` is also issued when a :term:`file object` is destroyed
without having been explicitly closed. While the deallocator for such without having been explicitly closed. While the deallocator for such
object ensures it closes the underlying operating system resource object ensures it closes the underlying operating system resource
(usually, a file descriptor), the delay in deallocating the object could (usually, a file descriptor), the delay in deallocating the object could
...@@ -411,7 +414,7 @@ Some smaller changes made to the core Python language are: ...@@ -411,7 +414,7 @@ Some smaller changes made to the core Python language are:
__main__:1: ResourceWarning: unclosed file <_io.BufferedWriter name='foo'> __main__:1: ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>
>>> >>>
(Added by Antoine Pitrou, :issue:`10093`.) (Added by Antoine Pitrou and Georg Brandl in :issue:`10093` and :issue:`477863`.)
* :class:`range` objects now support and *index* and *count* methods. This is * :class:`range` objects now support and *index* and *count* methods. This is
part of an effort to make more objects fully implement the :class:`collections.Sequence` part of an effort to make more objects fully implement the :class:`collections.Sequence`
...@@ -424,6 +427,11 @@ Some smaller changes made to the core Python language are: ...@@ -424,6 +427,11 @@ Some smaller changes made to the core Python language are:
(Contributed by Daniel Stuzback in :issue:`9213` and by Alexander Belopolsky (Contributed by Daniel Stuzback in :issue:`9213` and by Alexander Belopolsky
in :issue:`2690`.) in :issue:`2690`.)
* The :func:`callable` builtin function from Py2.x was resurrected. It provides
a concise, readable alternative to using an :term:`abstract base class` to in
an expression like ``isinstance(x, collections.Callable)``.
(See :issue:`10518`.)
New, Improved, and Deprecated Modules New, Improved, and Deprecated Modules
===================================== =====================================
...@@ -802,6 +810,15 @@ A number of small performance enhancements have been added: ...@@ -802,6 +810,15 @@ A number of small performance enhancements have been added:
(Patch by Florent Xicluna in :issue:`7622` and :issue:`7462`.) (Patch by Florent Xicluna in :issue:`7622` and :issue:`7462`.)
There were several other minor optimizations. Set differencing now runs faster
when one operand is much larger than the other (Patch by Andress Bennetts in
:issue:`8685`). The :meth:`array.repeat` method has a faster implementation
(:issue:`1569291` by Alexander Belopolsky). The :class:`BaseHTTPRequestHandler`
has more efficient buffering (:issue:`3709` by Andrew Schaaf). The
multi-argument form of :func:`operator.attrgetter` now function runs slightly
faster (:issue:`10160` by Christos Georgiou). And :class:`ConfigParser` loads
multi-line arguments a bit faster (:issue:`7113` by Łukasz Langa).
Unicode Unicode
======= =======
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment