[Python-Dev] Micro-optimizations by adding special-case bytecodes? (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Jun 28 10:20:54 EDT 2017
- Previous message (by thread): [Python-Dev] Micro-optimizations by adding special-case bytecodes?
- Next message (by thread): [Python-Dev] Micro-optimizations by adding special-case bytecodes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 28 Jun 2017 09:50:10 -0400 Ben Hoyt <benhoyt at gmail.com> wrote:
I've now got a patch to add new COMPAREISNONE and COMPAREISNOTNONE bytecodes to CPython to attempt to speed up the very common "is None" and "is not None" expressions. It's a very simple change overall. Here is my patch: https://gist.github.com/benhoyt/e5ba19afe7b869fd743c1c39fc2afdf8
I don't want to discourage you, but this is unlikely to produce significant speedups on real-world code. The simple reason is that comparing to None is not a bottleneck for any real application -- comparing to None is probably damn fast compared to everything else the real application does.
That said, it would be nice if you could get stable benchmark results to validate that theory (or not!) ;-)
Regards
Antoine.
- Previous message (by thread): [Python-Dev] Micro-optimizations by adding special-case bytecodes?
- Next message (by thread): [Python-Dev] Micro-optimizations by adding special-case bytecodes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]