1
0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-11-23 20:53:30 +01:00
Commit Graph

152 Commits

Author SHA1 Message Date
Hugo
c7a8b14049 Use setuptools_scm to simplify versioning during release 2020-02-26 18:37:41 +02:00
Hugo van Kemenade
1a2409dafd
Merge branch 'master' into rm-eol 2020-02-23 20:48:48 +02:00
Hugo
d53480c332 http -> https 2020-02-18 21:57:13 +02:00
Hugo
054c0b7a34 Drop EOL Python 2.5, 2.6, 3.2 and 3.3 2017-12-26 13:46:44 +02:00
Joakim Hamren
eb7d894f22 Integrated google's double-conversion lib
To fix issues with floating-point precision we've made use of Google's
double-conversion lib to handle conversions of doubles to and from strings.

In addition to fixing our precision problems this will improve double
encoding by 4-5x. Decoding is however slightly slower according to the
benchmarks - but accurate at least.

This change removes the double_precision encoding option and the
precise_float decoding option.
2017-02-14 12:20:04 +01:00
Joakim Hamren
c9f8318bd8 Fix for incorrect order when using OrderedDict 2017-02-07 02:02:38 +01:00
Joakim Hamren
7b5dc3172d New major version because of breaking changes 2017-02-06 23:45:38 +01:00
Joakim Hamren
50181f060f Removed serialization of date/datetime objects
To better align with the standard json module this removes ujson
default serialization of date/datetime objects to unix-timestamps.

Trying to serialize such an object will now raise a TypeError "repr(obj)
is not JSON serializable".
2017-02-06 23:27:29 +01:00
Joakim Hamren
5f98f01095 Removed support for __json__ method on str
This functionality caused a performance regression without a use-case
justifying the trade-off.
2017-02-06 23:27:29 +01:00
Joakim Hamren
53f85b1bd6 Removed generic serialization of objects/iterables
The behavior of ujson has always been to try to serialize all objects in
any way possible. This has been quite a deviation from other json
libraries, including Pythons standard json module, and the source of a
lot of confusion and bugs. Removing this quirk moves ultrajson closer to
the expected behavior.

Instead of trying to coerce serialization ultrajson will now throw a
TypeError: "repr(obj) is not JSON serializable" exception.
2017-02-06 23:27:25 +01:00
Joakim Hamren
ac4637fbc4 Following std json handling of None dict key
Previously a None dict item key would be outputted in JSON as "None".
To better align with the standard json module this was changed to output
"null". There's no proper representation of null object keys in JSON so
this is implementation specific but it seems more natural to follow
suit when it can be done without a significant performance hit.

Added and used branch prediction macros (LIKELY/UNLIKELY) as well.
2017-02-04 16:36:14 +01:00
Joakim Hamren
409c6d4006 Fix for overflowing long causing invalid json
This was caused by checking for "__json__" using PyObject_HasAttrString
which clears the error set by a previous long overflow. Thus this was dependent
on the order of processing of dict items, which explains why it was
seemingly random as the dict items are likely ordered by a hash of
the key.

This fixes GH224 and GH240.
2017-02-04 04:21:05 +01:00
Joakim Hamren
870ee48fe1 Fixes for sort_keys bug and a typo.
- Fixed segfault when using sort_keys=True on dict with unorderable keys (GH247)

    - Fixed refcount becoming negative when using sort_keys=True (GH243)

    - Fixed compile error when defining JSON_NO_EXTRA_WHITESPACE
      caused by a wrongly named variable. (GH245)
2017-02-04 01:07:52 +01:00
WGH
6cf6c7ff25 added "static" to C functions, where possible
1. It reduces clutter in symbol table.
2. It fixes issues with C99 inline semantics for functions
   marked as inline (#237, #180, #222), which manifests
   when compiled with GCC>=5.
2016-08-27 17:34:22 +03:00
Joakim Hamren
52bc13b6fc Bumping version to 1.35 2016-01-18 06:49:26 +01:00
Joakim Hamren
4da6667044 Merge branch 'master' of https://github.com/ngandhy/ultrajson into ngandhy-master
Conflicts:
	tests/tests.py
2016-01-18 06:38:34 +01:00
Joakim Hamrén
86bb8ffd10 Merge pull request #157 from wlanslovenija/raw-json
If an object has a __json__ method, use it when encoding
2016-01-15 05:06:19 +01:00
Joakim Hamrén
8c0edfb149 Merge pull request #203 from timdawborn/sort_keys_memory_leak
Corrected memory leak in sort_keys=True
2016-01-15 04:05:46 +01:00
Joakim Hamrén
2033cfc0bc Merge pull request #136 from b4hand/fix-typo
Fix typo.
2016-01-15 03:59:01 +01:00
Tim Dawborn
4c4624a7f8 Corrected memory leak due to not decrementing the reference count of the
list item being replaced.
2015-12-28 15:46:27 +11:00
Chris Huang
930dfa5525 Support for space indent for JSON encoding 2015-04-09 12:30:46 +02:00
Tim Dawborn
dcddcc4eba Corrected function dispatching for sort_keys. Added benchmarking section
for sort_keys.
2015-04-08 20:42:57 +02:00
Tim Dawborn
921716a3b7 Initial support for sort_keys parameter for JSON encoding. 2015-04-08 20:42:56 +02:00
Joakim Hamrén
d143d9d7bb Merge pull request #166 from leplatrem/option_disable_escape_slashes
Add option to disable forward slash escape
2015-04-08 13:51:30 +02:00
Mathieu Leplatre
d169b7ccbc Add option to disable forward slash escape
Ref issue #144
2015-03-31 23:41:51 +02:00
Mitar
a8f0f0f101 If an object has a __json__ method, use it when encoding.
It should return a raw JSON string which will be directly included in
the resulting JSON when encoding.
2014-12-29 10:13:46 +01:00
INADA Naoki
ab8f41954a Don't use deprecated PyUnicode_EncodeUTF8() 2014-12-26 11:31:33 +09:00
INADA Naoki
af1b05d74e Zero cost utf-8 encode for PyASCIIObject.
Before:
$ python3.4 -m timeit -n 10000 -s 'import ujson; x = ["a"*10]*100' 'ujson.dumps(x)'
10000 loops, best of 3: 15.8 usec per loop

After:
$ python -m timeit -n 10000 -s 'import ujson; x = ["a"*10]*100' 'ujson.dumps(x)'
10000 loops, best of 3: 7.14 usec per loop

Other unicode objects creates utf-8 cache in PyUnicode_AsUTF8AndSize().
It consume extra memory.
2014-12-26 01:54:45 +09:00
Joakim Hamrén
c9744834ab Merge pull request #142 from kevinbirch/support_unsigned_long_numerics
Support values between [0, 2^64 - 1]
2014-11-14 00:33:20 +01:00
kevin birch
cbd68782c8 add encoding support for unsigned long long 2014-11-11 18:25:27 -05:00
Joakim Hamren
7d28dc09ec Fixed segfault on invalid unicode char on python 3 2014-10-28 23:32:14 +01:00
kevin birch
6430079c3d support promotion of numeric values to unsigned long 2014-09-02 17:00:16 -04:00
Brandon Forehand
6b0209cdbb Fix typo. 2014-07-02 14:11:01 -07:00
Jonas Tarnstrom
0d76bd0849 Revert "Minor performance optimization"
This reverts commit 510a8fc6d7fd2af9fd39970ff3de4d9aac382706.
2014-04-16 08:42:48 +02:00
nik
3ab2a91bde Merge remote-tracking branch 'upstream/master' 2014-04-15 21:40:18 -07:00
Jonas Tarnstrom
510a8fc6d7 Minor performance optimization 2014-04-14 15:52:22 +02:00
Jonas Tarnstrom
4057771d9c Added private argument support for encoder path 2014-04-14 14:43:15 +02:00
Jonas Tarnstrom
9f3449b826 Updated copyright clause 2014-04-14 13:45:50 +02:00
Jonas Tarnstrom
06173a7354 Improved generic iterator support, revmoed iterBegin from encoder API, added test for blist 2014-04-14 13:39:03 +02:00
Jonas Tarnstrom
a62032db13 Bumped version 2014-04-14 13:39:01 +02:00
Mark Vismonte
2dca0063b5 [ujson] Fixing seg faults in unit tests
- The following unit tests were causing segfaults:
```
test_doubleLongDecimalIssue
test_invalidDoublePrecision
test_doublePrecisionTest
test_encodeDecimal
test_doubleLongIssue
test_encodeDecodeLongDecimal
```
- I changed a constant that couldn't be `const` because it can be overwritten by
  a passed in parameter
2014-02-02 00:58:57 +00:00
Nik
6cdb1ec65c c-api python keeps none as an object and doesn't convert to NULL as I assumed 2013-11-04 20:59:32 -08:00
Nik
0654f7b925 respect utcoffset 2013-11-04 20:41:51 -08:00
Jonas Tärnström
e339f5b9d7 Merge pull request #107 from romuloceccon/silence_unused_PyIntToINTXX_warning
Silence warning about unused PyIntToINTXX
2013-10-04 07:46:27 -07:00
Romulo A. Ceccon
343d36719b Silence warning about unused PyIntToINTXX
Make the declaration of PyIntToINT32/PyIntToINT64
conditional; otherwise the compiler always warns
about one of them being unused.
2013-09-26 17:15:59 -03:00
Romulo A. Ceccon
28b3bb371f Make idoublePrecision a true constant
Some older compilers might complain about
idoublePrecision not being a constant when
referenced inside the array declaration.
2013-09-26 17:06:08 -03:00
Romulo A. Ceccon
1f4b786efb Fixed support for distributions without decimal.py
ujson crashed Python if decimal.py wasn't
available. This fix makes ujson ignore the problem
and instead assume no Decimal object will be
passed in to ujson.dumps().
2013-08-19 08:23:41 -03:00
Kieran O'Mahony
6242c253af whitespace fix 2013-06-18 14:21:43 +01:00
Jonas Tarnstrom
4e4dc5e4cc Added 2 bytes to the string reservation macro to guaranteed to able to hold the quotes 2013-06-11 08:09:57 +02:00
Jonas Tarnstrom
4073babe2c Merged (line-by-line prv pointer additions from ujson4c project. Bumped version 2013-06-10 12:44:04 +02:00