Skip to content

PERF: fix JSON performance regression from 0.12 (GH5765) #6137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Bug Fixes
- Regresssion in handling of empty Series as indexers to Series (:issue:`5877`)
- Bug in internal caching, related to (:issue:`5727`)
- Testing bug in reading json/msgpack from a non-filepath on windows under py3 (:issue:`5874`)
- Fix performance regression in JSON IO (:issue:`5765`)
- Bug when assigning to .ix[tuple(...)] (:issue:`5896`)
- Bug in fully reindexing a Panel (:issue:`5905`)
- Bug in idxmin/max with object dtypes (:issue:`5914`)
Expand Down
22 changes: 15 additions & 7 deletions pandas/src/ujson/lib/ultrajsondec.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,15 +894,23 @@ JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer, size_t cbBuf

ds.dec = dec;

locale = strdup(setlocale(LC_NUMERIC, NULL));
if (!locale)
locale = setlocale(LC_NUMERIC, NULL);
if (strcmp(locale, "C"))
{
return SetError(&ds, -1, "Could not reserve memory block");
locale = strdup(locale);
if (!locale)
{
return SetError(&ds, -1, "Could not reserve memory block");
}
setlocale(LC_NUMERIC, "C");
ret = decode_any (&ds);
setlocale(LC_NUMERIC, locale);
free(locale);
}
else
{
ret = decode_any (&ds);
}
setlocale(LC_NUMERIC, "C");
ret = decode_any (&ds);
setlocale(LC_NUMERIC, locale);
free(locale);

if (ds.escHeap)
{
Expand Down
24 changes: 16 additions & 8 deletions pandas/src/ujson/lib/ultrajsonenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,16 +917,24 @@ char *JSON_EncodeObject(JSOBJ obj, JSONObjectEncoder *enc, char *_buffer, size_t
enc->end = enc->start + _cbBuffer;
enc->offset = enc->start;

locale = strdup(setlocale(LC_NUMERIC, NULL));
if (!locale)
locale = setlocale(LC_NUMERIC, NULL);
if (strcmp(locale, "C"))
{
SetError(NULL, enc, "Could not reserve memory block");
return NULL;
locale = strdup(locale);
if (!locale)
{
SetError(NULL, enc, "Could not reserve memory block");
return NULL;
}
setlocale(LC_NUMERIC, "C");
encode (obj, enc, NULL, 0);
setlocale(LC_NUMERIC, locale);
free(locale);
}
else
{
encode (obj, enc, NULL, 0);
}
setlocale(LC_NUMERIC, "C");
encode (obj, enc, NULL, 0);
setlocale(LC_NUMERIC, locale);
free(locale);

Buffer_Reserve(enc, 1);
if (enc->errorMsg)
Expand Down
Loading