Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2397dd58
Kaydet (Commit)
2397dd58
authored
Kas 04, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10314: improve performance of JSON encoding with sort_keys=True
üst
5ee89cf1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
_json.c
Modules/_json.c
+25
-20
No files found.
Modules/_json.c
Dosyayı görüntüle @
2397dd58
...
...
@@ -1387,8 +1387,6 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
PyObject
*
item
=
NULL
;
int
skipkeys
;
Py_ssize_t
idx
;
PyObject
*
mapping
;
static
PyObject
*
code
=
NULL
;
if
(
open_dict
==
NULL
||
close_dict
==
NULL
||
empty_dict
==
NULL
)
{
open_dict
=
PyUnicode_InternFromString
(
"{"
);
...
...
@@ -1430,30 +1428,37 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
}
if
(
PyObject_IsTrue
(
s
->
sort_keys
))
{
if
(
code
==
NULL
)
{
code
=
Py_CompileString
(
"sorted(d.items(), key=lambda kv: kv[0])"
,
"_json.c"
,
Py_eval_input
);
if
(
code
==
NULL
)
goto
bail
;
}
mapping
=
PyDict_New
();
if
(
mapping
==
NULL
)
/* First sort the keys then replace them with (key, value) tuples. */
Py_ssize_t
i
,
nitems
;
items
=
PyMapping_Keys
(
dct
);
if
(
items
==
NULL
)
goto
bail
;
if
(
PyDict_SetItemString
(
mapping
,
"d"
,
dct
)
==
-
1
)
{
Py
_DECREF
(
mapping
);
if
(
!
PyList_Check
(
items
)
)
{
Py
Err_SetString
(
PyExc_ValueError
,
"keys must return list"
);
goto
bail
;
}
items
=
PyEval_EvalCode
((
PyCodeObject
*
)
code
,
PyEval_GetGlobals
(),
mapping
);
Py_DECREF
(
mapping
);
}
else
{
items
=
PyMapping_Items
(
dct
);
if
(
PyList_Sort
(
items
)
<
0
)
goto
bail
;
nitems
=
PyList_GET_SIZE
(
items
);
for
(
i
=
0
;
i
<
nitems
;
i
++
)
{
PyObject
*
key
,
*
value
;
key
=
PyList_GET_ITEM
(
items
,
i
);
value
=
PyDict_GetItem
(
dct
,
key
);
item
=
PyTuple_Pack
(
2
,
key
,
value
);
if
(
item
==
NULL
)
goto
bail
;
PyList_SET_ITEM
(
items
,
i
,
item
);
Py_DECREF
(
key
);
}
if
(
items
==
NULL
)
}
else
{
items
=
PyMapping_Items
(
dct
);
}
if
(
items
==
NULL
)
goto
bail
;
it
=
PyObject_GetIter
(
items
);
Py_DECREF
(
items
);
if
(
it
==
NULL
)
Py_DECREF
(
items
);
if
(
it
==
NULL
)
goto
bail
;
skipkeys
=
PyObject_IsTrue
(
s
->
skipkeys
);
idx
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment