<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/cpython-git.git, branch faster-bytes-iter</title>
<subtitle>github.com: python/cpython.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/'/>
<entry>
<title>A (very) slight speed improvement for iterating over bytes</title>
<updated>2020-08-02T22:51:54+00:00</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2020-08-02T22:51:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=66850f6f4e22e8652910311de68fe8b023dedcfc'/>
<id>66850f6f4e22e8652910311de68fe8b023dedcfc</id>
<content type='text'>
My mentee @xvxvxvxvxv noticed that iterating over array.array is
slightly faster than iterating over bytes.  Looking at the source I
observed that arrayiter_next() calls `getitem(ao, it-&gt;index++)` wheras
striter_next() uses the idiom (paraphrased)

    item = PyLong_FromLong(seq-&gt;ob_sval[it-&gt;it_index]);
    if (item != NULL)
        ++it-&gt;it_next;
    return item;

I'm not 100% sure but I think that the second version has fewer
opportunity for the CPU to overlap the `index++` operation with the
rest of the code (which in both cases involves a call).  So here I am
optimistically incrementing the index -- if the PyLong_FromLong() call
fails, this will leave the iterator pointing at the next byte, but
honestly I doubt that anyone would seriously consider resuming use of
the iterator after that kind of failure (it would have to be a
MemoryError).  And the author of arrayiter_next() made the same
consideration (or never ever gave it a thought :-).

With this, a loop like

    for _ in b: pass

is now slightly *faster* than the same thing over an equivalent array,
rather than slightly *slower* (in both cases a few percent).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
My mentee @xvxvxvxvxv noticed that iterating over array.array is
slightly faster than iterating over bytes.  Looking at the source I
observed that arrayiter_next() calls `getitem(ao, it-&gt;index++)` wheras
striter_next() uses the idiom (paraphrased)

    item = PyLong_FromLong(seq-&gt;ob_sval[it-&gt;it_index]);
    if (item != NULL)
        ++it-&gt;it_next;
    return item;

I'm not 100% sure but I think that the second version has fewer
opportunity for the CPU to overlap the `index++` operation with the
rest of the code (which in both cases involves a call).  So here I am
optimistically incrementing the index -- if the PyLong_FromLong() call
fails, this will leave the iterator pointing at the next byte, but
honestly I doubt that anyone would seriously consider resuming use of
the iterator after that kind of failure (it would have to be a
MemoryError).  And the author of arrayiter_next() made the same
consideration (or never ever gave it a thought :-).

With this, a loop like

    for _ in b: pass

is now slightly *faster* than the same thing over an equivalent array,
rather than slightly *slower* (in both cases a few percent).
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-40979: refactored typing.rst; (mostly) same content, new sub-sections and ordering (#21574)</title>
<updated>2020-08-02T22:32:36+00:00</updated>
<author>
<name>Luciano Ramalho</name>
<email>luciano@ramalho.org</email>
</author>
<published>2020-08-02T22:32:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=ab72fdeb82c3ab045b480cd4bb4f928c12653ecb'/>
<id>ab72fdeb82c3ab045b480cd4bb4f928c12653ecb</id>
<content type='text'>
Also added PEP 585 deprecation notes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also added PEP 585 deprecation notes.
</pre>
</div>
</content>
</entry>
<entry>
<title>random module: Convert a "while 1" to "while True (GH-21700)</title>
<updated>2020-08-02T19:03:32+00:00</updated>
<author>
<name>Raymond Hettinger</name>
<email>rhettinger@users.noreply.github.com</email>
</author>
<published>2020-08-02T19:03:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=6a613f90bf13038255bca028feeab6fad816edfd'/>
<id>6a613f90bf13038255bca028feeab6fad816edfd</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-41421: Algebraic simplification for random.paretovariate() (GH-21695)</title>
<updated>2020-08-01T08:18:26+00:00</updated>
<author>
<name>Raymond Hettinger</name>
<email>rhettinger@users.noreply.github.com</email>
</author>
<published>2020-08-01T08:18:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=5c3270939c09e4c8e80fd26449b718a998701912'/>
<id>5c3270939c09e4c8e80fd26449b718a998701912</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-40360: Handle PendingDeprecationWarning in test_lib2to3. (GH-21694)</title>
<updated>2020-07-31T10:50:48+00:00</updated>
<author>
<name>Karthikeyan Singaravelan</name>
<email>tir.karthi@gmail.com</email>
</author>
<published>2020-07-31T10:50:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=cadda52d974937069eeebea1cca4229e2bd400df'/>
<id>cadda52d974937069eeebea1cca4229e2bd400df</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)</title>
<updated>2020-07-30T09:03:00+00:00</updated>
<author>
<name>Mark Shannon</name>
<email>mark@hotpy.org</email>
</author>
<published>2020-07-30T09:03:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=6e8128f02e1d36e38e5866f9dc36e051caa47bc9'/>
<id>6e8128f02e1d36e38e5866f9dc36e051caa47bc9</id>
<content type='text'>
* Move 'peephole' optimizations into compile.c and perform them directly on the CFG.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Move 'peephole' optimizations into compile.c and perform them directly on the CFG.</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-41426 Fix grammar in curses.getmouse() documentation (GH-21677)</title>
<updated>2020-07-29T18:36:46+00:00</updated>
<author>
<name>Sebastien Williams-Wynn</name>
<email>s.williamswynn.mail@gmail.com</email>
</author>
<published>2020-07-29T18:36:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=ba18c0b13ba3c08077ea3db6658328523823a33f'/>
<id>ba18c0b13ba3c08077ea3db6658328523823a33f</id>
<content type='text'>
Automerge-Triggered-By: @brettcannon</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Automerge-Triggered-By: @brettcannon</pre>
</div>
</content>
</entry>
<entry>
<title>closes bpo-38156: Always handle interrupts in PyOS_StdioReadline. (GH-21569)</title>
<updated>2020-07-29T00:57:12+00:00</updated>
<author>
<name>Benjamin Peterson</name>
<email>benjamin@python.org</email>
</author>
<published>2020-07-29T00:57:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=a74eea238f5baba15797e2e8b570d153bc8690a7'/>
<id>a74eea238f5baba15797e2e8b570d153bc8690a7</id>
<content type='text'>
This consolidates the handling of my_fgets return values, so that interrupts are always handled, even if they come after EOF.

 I believe PyOS_StdioReadline is still buggy in that I/O errors will not result in a proper Python exception being set. However, that is a separate issue.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This consolidates the handling of my_fgets return values, so that interrupts are always handled, even if they come after EOF.

 I believe PyOS_StdioReadline is still buggy in that I/O errors will not result in a proper Python exception being set. However, that is a separate issue.</pre>
</div>
</content>
</entry>
<entry>
<title>Remove incorrect mention of method.__class__ in descriptor docs (GH-21665)</title>
<updated>2020-07-28T23:56:26+00:00</updated>
<author>
<name>Yonatan Goldschmidt</name>
<email>yon.goldschmidt@gmail.com</email>
</author>
<published>2020-07-28T23:56:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=f6a16e8a82d5673bc1897e0f251deb5173095689'/>
<id>f6a16e8a82d5673bc1897e0f251deb5173095689</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix `List_Append` description, list is extracted at TOS1[-i] (GH-21465)</title>
<updated>2020-07-28T16:51:33+00:00</updated>
<author>
<name>Xiang Zhang</name>
<email>angwerzx@126.com</email>
</author>
<published>2020-07-28T16:51:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=34cd3e9f6a87f9c50edac893b0d5ae46c4e48ee3'/>
<id>34cd3e9f6a87f9c50edac893b0d5ae46c4e48ee3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
