[New-bugs-announce] [issue30111] json module: encoder optimization

Marian Horban report at bugs.python.org
Thu Apr 20 05:15:30 EDT 2017


New submission from Marian Horban:

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
>>> def flocal(name=False):
...     for i in range(5):
...         x = name
... 
>>> timeit.timeit("flocal()", "from __main__ import flocal", number=10000000)
5.0455567836761475
>>> 
>>> def fbuilt_in():
...     for i in range(5):
...         x = False
... 
>>> 
>>> timeit.timeit("fbuilt_in()", "from __main__ import fbuilt_in", number=10000000)
5.451796054840088

----------
components: Library (Lib)
files: encoder_opt.patch
keywords: patch
messages: 291955
nosy: Marian Horban 2
priority: normal
severity: normal
status: open
title: json module: encoder optimization
type: performance
versions: Python 2.7
Added file: http://bugs.python.org/file46815/encoder_opt.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30111>
_______________________________________


More information about the New-bugs-announce mailing list