You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to improve performance of json module encoder.
Since access to local variables is faster than to globals/builtins I propose to use locals instead of globals.
Small test of such improvement:
>>> import timeit
>>> defflocal(name=False):
... for i inrange(5):
... x = name
...
>>> timeit.timeit("flocal()", "from __main__ import flocal", number=10000000)
5.0455567836761475
>>>
>>> deffbuilt_in():
... for i inrange(5):
... x =False
...
>>>
>>> timeit.timeit("fbuilt_in()", "from __main__ import fbuilt_in", number=10000000)
5.451796054840088
New features can be only added to the default branch. True and False are not global variables but keywords in Python 3. And in any case the json module is accelerated by C implementation which much faster than any microoptimized Python code.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: