Speed Improvements in Python 3.7
Anthony Shaw (via Hacker News):
The new
LOAD_METHOD
opcode replaces loading bound methods as attributes and just calling them as normal functions. Remember,LOAD_METHOD
andCALL_METHOD
are faster thanCALL_FUNCTION
for instance methods.[…]
Keyword arguments require special treatment in the execution loop because there is no equivalent in C (which CPython is written in), some extra code has to compile 2 tuples to pass to the method.
[…]
In Python 3.7, the expected Unicode code-point size is no longer hard-coded and the methods are optimised long (mostly unusual) characters.
[…]
Matching and searching case-insensitive regular expressions is much slower than matching and searching case-sensitive regular expressions. Case-insensitivity requires converting every character in input string to lower case and disables some optimizations. But there are only 2669 cased characters (52 in ASCII mode). For all other characters in the pattern we can use case-sensitive matching.