[issue30111] json module: encoder optimization

2017-04-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

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.

--
nosy: +serhiy.storchaka
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30111] json module: encoder optimization

2017-04-20 Thread Marian Horban

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

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com