Re: [Python-Dev] More optimisation ideas

2016年1月30日 06:47:42 -0800

On 29.01.16 19:05, Steve Dower wrote:
This is probably the code snippet that bothered me the most:
 ### Encoding table
 encoding_table=codecs.charmap_build(decoding_table)
It shows up in many of the encodings modules, and while it is not a bad
function in itself, we are obviously generating a known data structure
on every startup. Storing these in static data is a tradeoff between
disk space and startup performance, and one I think it likely to be
worthwhile.
$ ./python -m timeit -s "import codecs; from encodings.cp437 import decoding_table" -- "codecs.charmap_build(decoding_table)"
100000 loops, best of 3: 4.36 usec per loop
Getting rid from charmap_build() would save you at most 4.4 microseconds per encoding. 0.0005 seconds if you have imported *all* standard encodings!
And how you expected to store encoding_table in more efficient way?
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to