Message121081
| Author |
pitrou |
| Recipients |
alex, belopolsky, benjamin.peterson, dmalcolm, jhylton, nnorwitz, pitrou, rhettinger, sdahlbac, thomaslee, titanstar |
| Date |
2010年11月12日.21:24:29 |
| SpamBayes Score |
2.508902e-10 |
| Marked as misclassified |
No |
| Message-id |
<1289597080.96.0.9732660757.issue10401@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Here is the Nth patch for a globals/builtins cache. As other caches at the same kind, it shows very small to no gain on non-micro benchmarks, showing that contrary to popular belief, globals/builtins lookup are not a major roadblock in today's Python performance.
However, this patch could be useful in combination with other optimizations such as issue10399. Indeed, using the globals/builtins version id, it is easy and very cheap to detect whether the function pointed to by a global name has changed or not.
As for micro-benchmarks, they show that there is indeed a good improvement on builtins lookups:
$ ./python -m timeit "x=len;x=len;x=len;x=len;x=len;x=len;x=len;x=len;x=len;x=len;"
-> without patch:
1000000 loops, best of 3: 0.282 usec per loop
-> with patch:
10000000 loops, best of 3: 0.183 usec per loop |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年11月12日 21:24:41 | pitrou | set | recipients:
+ pitrou, jhylton, nnorwitz, rhettinger, belopolsky, sdahlbac, titanstar, thomaslee, benjamin.peterson, alex, dmalcolm |
| 2010年11月12日 21:24:40 | pitrou | set | messageid: <1289597080.96.0.9732660757.issue10401@psf.upfronthosting.co.za> |
| 2010年11月12日 21:24:29 | pitrou | link | issue10401 messages |
| 2010年11月12日 21:24:29 | pitrou | create |
|