Ralph Heinkel added the comment:

This patch was implemented on Europython 2013 sprint. It's my first addition to 
Python core ever so please bear with me if it's not perfect. 

Decimal support is implemented both in the C and Python JSON code.

There is one peculiarity to mention about the Decimal addition in function 
_json.c:encoder_listencode_obj() of my patch:
The addition of

    else if (PyObject_IsInstance(obj, (PyObject*)PyDecimalType)) {
        PyObject *encoded = encoder_encode_decimal(s, obj);
        if (encoded == NULL)
            return -1;
        return _steal_accumulate(acc, encoded);
    }

was has to be located AFTER lists and dicts are handled in the JSON encoder, 
otherwise the unittest "test_highly_nested_objects_encoding()" from 
test_recursion.py fails with a nasty, unrecoverable Python exception.
My guess is that this is due additional stack allocation when the stack space 
is almost used up by the deeply nested recursion code.

----------
hgrepos: +202
keywords: +patch
nosy: +ralhei
Added file: http://bugs.python.org/file30836/json_decimal.patch

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

Reply via email to