New submission from Antoine Pitrou <pit...@free.fr>:

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

----------
components: Library (Lib)
files: jsonnumbers.patch
keywords: patch
messages: 133891
nosy: mark.dickinson, pitrou, rhettinger
priority: normal
severity: normal
stage: patch review
status: open
title: Optimize parsing of JSON numbers
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file21681/jsonnumbers.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11856>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to