<br><br>On Friday, January 26, 2018, Victor Stinner <<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Well, I wrote <a href="https://faster-cpython.readthedocs.io/" target="_blank">https://faster-cpython.readthe<wbr>docs.io/</a> website to answer<br>
to such question.<br>
<br>
See for example <a href="https://faster-cpython.readthedocs.io/mutable.html" target="_blank">https://faster-cpython.readthe<wbr>docs.io/mutable.html</a><br>
"Everything in Python is mutable".</blockquote><div><br></div><div>Thanks!</div><div><br></div><div>"""</div><div><p style="line-height:24px;margin:0px 0px 24px;font-size:16px;color:rgb(64,64,64);font-family:Lato,proxima-nova,"Helvetica Neue",Arial,sans-serif;background-color:rgb(252,252,252)">Contents:</p><div style="color:rgb(64,64,64);font-family:Lato,proxima-nova,"Helvetica Neue",Arial,sans-serif;font-size:16px;background-color:rgb(252,252,252)"><ul style="margin:0px 0px 24px;padding:0px;list-style-position:initial;line-height:24px"><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/cpython37.html" style="color:rgb(155,89,182)" target="_blank">Projects to optimize CPython 3.7</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/cpython36.html" style="color:rgb(155,89,182)" target="_blank">Projects to optimize CPython 3.6</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/notes_2017.html" style="color:rgb(155,89,182)" target="_blank">Notes on Python and CPython performance, 2017</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/fat_python.html" style="color:rgb(155,89,182)" target="_blank">FAT Python</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/mutable.html" style="color:rgb(155,89,182)" target="_blank">Everything in Python is mutable</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/optimizations.html" style="color:rgb(155,89,182)" target="_blank">Optimizations</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/bytecode.html" style="color:rgb(155,89,182)" target="_blank">Python bytecode</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/c_api.html" style="color:rgb(155,89,182)" target="_blank">Python C API</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/ast_optimizer.html" style="color:rgb(155,89,182)" target="_blank">AST Optimizers</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/registervm.html" style="color:rgb(155,89,182)" target="_blank">Register-based Virtual Machine for Python</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/readonly.html" style="color:rgb(155,89,182)" target="_blank">Read-only Python</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/history.html" style="color:rgb(155,89,182)" target="_blank">History of Python optimizations</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/misc.html" style="color:rgb(155,89,182)" target="_blank">Misc</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/gil.html" style="color:rgb(155,89,182)" target="_blank">Kill the GIL?</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/implementations.html" style="color:rgb(155,89,182)" target="_blank">Implementations of Python</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/benchmarks.html" style="color:rgb(155,89,182)" target="_blank">Benchmarks</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/pypy.html" style="color:rgb(155,89,182)" target="_blank">Random notes about PyPy</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/talks.html" style="color:rgb(155,89,182)" target="_blank">Talks</a></li><li style="list-style:disc;margin-left:24px"><a href="https://faster-cpython.readthedocs.io/links.html" style="color:rgb(155,89,182)" target="_blank">Links</a></li></ul></div></div><div> """</div><div><br></div><div>Pandas & Cython</div><div><a href="https://pandas.pydata.org/pandas-docs/stable/enhancingperf.html" target="_blank">https://pandas.pydata.org/<wbr>pandas-docs/stable/<wbr>enhancingperf.html</a><br></div><div><br></div><div><span style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";background-color:rgb(250,251,252)">"Vaex uses memory mapping, zero memory copy policy and lazy computations for best performance (no memory wasted)."</span><br></div><div><a href="https://github.com/maartenbreddels/vaex">https://github.com/maartenbreddels/vaex</a><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Victor<br>
<br>
2018-01-26 22:35 GMT+01:00 Pau Freixes <<a href="mailto:pfreixes@gmail.com" target="_blank">pfreixes@gmail.com</a>>:<br>
> Hi,<br>
><br>
> This mail is the consequence of a true story, a story where CPython<br>
> got defeated by Javascript, Java, C# and Go.<br>
><br>
> One of the teams of the company where Im working had a kind of<br>
> benchmark to compare the different languages on top of their<br>
> respective "official" web servers such as Node.js, Aiohttp, Dropwizard<br>
> and so on.  The test by itself was pretty simple and tried to test the<br>
> happy path of the logic, a piece of code that fetches N rules from<br>
> another system and then apply them to X whatevers also fetched from<br>
> another system, something like that<br>
><br>
> def filter(rule, whatever):<br>
>     if rule.x in whatever.x:<br>
>         return True<br>
><br>
> rules = get_rules()<br>
> whatevers = get_whatevers()<br>
> for rule in rules:<br>
>     for whatever in whatevers:<br>
>         if filter(rule, whatever):<br>
>             cnt = cnt + 1<br>
><br>
> return cnt<br>
><br>
><br>
> The performance of Python compared with the other languages was almost<br>
> x10 times slower. It's true that they didn't optimize the code, but<br>
> they did not for any language having for all of them the same cost in<br>
> terms of iterations.<br>
><br>
> Once I saw the code I proposed a pair of changes, remove the call to<br>
> the filter function making it "inline" and caching the rule's<br>
> attributes, something like that<br>
><br>
> for rule in rules:<br>
>     x = rule.x<br>
>     for whatever in whatevers:<br>
>         if x in whatever.x:<br>
>             cnt += 1<br>
><br>
> The performance of the CPython boosted x3/x4 just doing these "silly" things.<br>
><br>
> The case of the rule cache IMHO is very striking, we have plenty<br>
> examples in many repositories where the caching of none local<br>
> variables is a widely used pattern, why hasn't been considered a way<br>
> to do it implicitly and by default?<br>
><br>
> The case of the slowness to call functions in CPython is quite<br>
> recurrent and looks like its an unsolved problem at all.<br>
><br>
> Sure I'm missing many things, and I do not have all of the<br>
> information. This mail wants to get all of this information that might<br>
> help me to understand why we are here - CPython - regarding this two<br>
> slow patterns.<br>
><br>
> This could be considered an unimportant thing, but its more relevant<br>
> than someone could expect, at least IMHO. If the default code that you<br>
> can write in a language is by default slow and exists an alternative<br>
> to make it faster, this language is doing something wrong.<br>
><br>
> BTW: pypy looks like is immunized [1]<br>
><br>
> [1] <a href="https://gist.github.com/pfreixes/d60d00761093c3bdaf29da025a004582" target="_blank">https://gist.github.com/pfreix<wbr>es/d60d00761093c3bdaf29da025a0<wbr>04582</a><br>
> --<br>
> --pau<br>
> ______________________________<wbr>_________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</blockquote>