Author: Antonio Cuni <[email protected]> Branch: fastjson Changeset: r64980:b0370b823d98 Date: 2013-06-25 18:38 +0200 http://bitbucket.org/pypy/pypy/changeset/b0370b823d98/
Log: use the _fastjson speedup, if present diff --git a/lib-python/2.7/json/__init__.py b/lib-python/2.7/json/__init__.py --- a/lib-python/2.7/json/__init__.py +++ b/lib-python/2.7/json/__init__.py @@ -105,6 +105,12 @@ __author__ = 'Bob Ippolito <[email protected]>' +try: + # PyPy speedup, the interface is different than CPython's _json + import _fastjson +except ImportError: + _fastjson = None + from .decoder import JSONDecoder from .encoder import JSONEncoder @@ -241,7 +247,6 @@ _default_decoder = JSONDecoder(encoding=None, object_hook=None, object_pairs_hook=None) - def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing @@ -323,7 +328,10 @@ if (cls is None and encoding is None and object_hook is None and parse_int is None and parse_float is None and parse_constant is None and object_pairs_hook is None and not kw): - return _default_decoder.decode(s) + if _fastjson and not isinstance(s, unicode): + return _fastjson.loads(s) + else: + return _default_decoder.decode(s) if cls is None: cls = JSONDecoder if object_hook is not None: _______________________________________________ pypy-commit mailing list [email protected] http://mail.python.org/mailman/listinfo/pypy-commit
