Message133891
In Python 3.x, parsing JSON numbers involve calling PyLong_FromUnicode or PyFloat_FromString with an unicode object. These functions are quite costly because they call PyUnicode_TransformDecimalToASCII(). But JSON numbers are always pure ASCII. This patch does the ASCII conversion ourselves.
Small benchmark with integers:
./python -m timeit -s \
"from json import loads, dumps; d=list(i for i in range(1000)); s=dumps(d)" \
"loads(s)"
-> without patch: 705 usec per loop
-> with patch: 103 usec per loop |
|
Date |
User |
Action |
Args |
2011-04-16 12:19:22 | pitrou | set | recipients:
+ pitrou, rhettinger, mark.dickinson |
2011-04-16 12:19:22 | pitrou | set | messageid: <1302956362.08.0.216789404235.issue11856@psf.upfronthosting.co.za> |
2011-04-16 12:19:20 | pitrou | link | issue11856 messages |
2011-04-16 12:19:20 | pitrou | create | |
|