This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ralhei
Recipients Arfrever, eric.araujo, ezio.melotti, jcea, mark.dickinson, pitrou, ralhei, rhettinger, serhiy.storchaka, skrah
Date 2013-07-07.08:10:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373184603.73.0.733765596323.issue16535@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-07-07 08:10:04ralheisetrecipients: + ralhei, rhettinger, jcea, mark.dickinson, pitrou, ezio.melotti, eric.araujo, Arfrever, skrah, serhiy.storchaka
2013-07-07 08:10:03ralheisetmessageid: <1373184603.73.0.733765596323.issue16535@psf.upfronthosting.co.za>
2013-07-07 08:10:03ralheilinkissue16535 messages
2013-07-07 08:10:03ralheicreate