Skip to main content

Timeline for answer to Why does Python code run faster in a function? by Alex Riley

Current License: CC BY-SA 3.0

Post Revisions

13 events
when toggle format what by license comment
Mar 29, 2019 at 15:03 comment added ShadowRanger Even that unpredictable jump doesn't happen in most builds of CPython, because of the new (as of Python 3.1, enabled by default in 3.2) computed gotos behavior; when used, the PREDICT macro is completely disabled; instead most cases end in a DISPATCH that branches directly. But on branch predicting CPUs, the effect is similar to that of PREDICT, since branching (and prediction) is per opcode, increasing the odds of successful branch prediction.
Mar 29, 2019 at 14:56 comment added ShadowRanger Minor update: As of CPython 3.6, the savings from prediction go down a bit; instead of two unpredictable branches, there is only one. The change is due to the switch from bytecode to wordcode; now all "wordcodes" have an argument, it's just zero-ed out when the instruction doesn't logically take an argument. Thus, the HAS_ARG test never occurs (except when low level tracing is enabled both at compile and runtime, which no normal build does), leaving only one unpredictable jump.
S Mar 28, 2018 at 9:16 history suggested rrao CC BY-SA 3.0
corrected spelling
Mar 28, 2018 at 8:03 review Suggested edits
S Mar 28, 2018 at 9:16
Aug 6, 2015 at 19:55 history edited Alex Riley CC BY-SA 3.0
added 494 characters in body
Apr 22, 2015 at 21:37 history edited Alex Riley CC BY-SA 3.0
deleted 9 characters in body
Apr 22, 2015 at 20:05 history edited Alex Riley CC BY-SA 3.0
added 20 characters in body
Apr 8, 2015 at 12:21 history edited Alex Riley CC BY-SA 3.0
deleted 236 characters in body
Apr 6, 2015 at 16:27 history edited Alex Riley CC BY-SA 3.0
added 63 characters in body
Apr 6, 2015 at 10:40 history edited Alex Riley CC BY-SA 3.0
added 95 characters in body
Apr 5, 2015 at 23:01 history edited Alex Riley CC BY-SA 3.0
added 61 characters in body
Apr 5, 2015 at 22:24 history edited Alex Riley CC BY-SA 3.0
deleted 93 characters in body
Apr 5, 2015 at 18:45 history answered Alex Riley CC BY-SA 3.0