Issue #9 open

add ujson

Zoltán Szalai
created an issue


is there any reason why ujson is not added yet? tried it out with the benchmark script and it seems to be very fast:

Total Read Write Implementation

0.185 0.118 0.068 ujson

0.256 0.118 0.137 django.utils.simplejson

0.262 0.120 0.142 simplejson

0.307 0.177 0.130 yajl

0.318 0.168 0.149 jsonlib2

0.336 0.119 0.216 cjson

0.454 0.297 0.157 json

0.626 0.465 0.161 jsonlib

Not installed: jsonpickle

Comments (7)

  1. Rune Halvorsen repo owner
    • changed status to open

    i've wanted to add it, but I'm not sure how to do so in a good way. the issue is that ujson uses a different approach to error handling than the other implementations. were most implementations raise exceptions, ujson returns empty content and similar. That's a reasonable approach, but it means you could write a program that relies on anyjson that fails when using ujson, but not when using other implementations. (or the other way around). Any opinions on a reasonable way to deal with this would be most appreciated!

  2. Melvii Ts

    Well, ujson now almost the same with the standard json module. So just adding a line ("ujson", "dumps", TypeError, "loads", ValueError, "load"), in _modules variable, it should work.

  3. Melvii Ts
    Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ujson
    >>> ujson.loads("")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: Expected object or value
    >>> ujson.dumps(Ellipsis)  # seems it's never failed
    >>> ujson.__version__
  4. Log in to comment