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
f645451d
Kaydet (Commit)
f645451d
authored
Nis 25, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #11856: Speed up parsing of JSON numbers.
üst
54afa550
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
15 deletions
+33
-15
NEWS
Misc/NEWS
+2
-0
_json.c
Modules/_json.c
+31
-15
No files found.
Misc/NEWS
Dosyayı görüntüle @
f645451d
...
@@ -113,6 +113,8 @@ Core and Builtins
...
@@ -113,6 +113,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
11856
:
Speed
up
parsing
of
JSON
numbers
.
-
Issue
#
11005
:
threading
.
RLock
().
_release_save
()
raises
a
RuntimeError
if
the
-
Issue
#
11005
:
threading
.
RLock
().
_release_save
()
raises
a
RuntimeError
if
the
lock
was
not
acquired
.
lock
was
not
acquired
.
...
...
Modules/_json.c
Dosyayı görüntüle @
f645451d
...
@@ -842,7 +842,8 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_
...
@@ -842,7 +842,8 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_
Py_ssize_t
idx
=
start
;
Py_ssize_t
idx
=
start
;
int
is_float
=
0
;
int
is_float
=
0
;
PyObject
*
rval
;
PyObject
*
rval
;
PyObject
*
numstr
;
PyObject
*
numstr
=
NULL
;
PyObject
*
custom_func
;
/* read a sign if it's there, make sure it's not the end of the string */
/* read a sign if it's there, make sure it's not the end of the string */
if
(
str
[
idx
]
==
'-'
)
{
if
(
str
[
idx
]
==
'-'
)
{
...
@@ -895,22 +896,37 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_
...
@@ -895,22 +896,37 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_
}
}
}
}
/* copy the section we determined to be a number */
if
(
is_float
&&
s
->
parse_float
!=
(
PyObject
*
)
&
PyFloat_Type
)
numstr
=
PyUnicode_FromUnicode
(
&
str
[
start
],
idx
-
start
);
custom_func
=
s
->
parse_float
;
if
(
numstr
==
NULL
)
else
if
(
!
is_float
&&
s
->
parse_int
!=
(
PyObject
*
)
&
PyLong_Type
)
return
NULL
;
custom_func
=
s
->
parse_int
;
if
(
is_float
)
{
else
/* parse as a float using a fast path if available, otherwise call user defined method */
custom_func
=
NULL
;
if
(
s
->
parse_float
!=
(
PyObject
*
)
&
PyFloat_Type
)
{
rval
=
PyObject_CallFunctionObjArgs
(
s
->
parse_float
,
numstr
,
NULL
);
if
(
custom_func
)
{
}
/* copy the section we determined to be a number */
else
{
numstr
=
PyUnicode_FromUnicode
(
&
str
[
start
],
idx
-
start
);
rval
=
PyFloat_FromString
(
numstr
);
if
(
numstr
==
NULL
)
}
return
NULL
;
rval
=
PyObject_CallFunctionObjArgs
(
custom_func
,
numstr
,
NULL
);
}
}
else
{
else
{
/* no fast path for unicode -> int, just call */
Py_ssize_t
i
,
n
;
rval
=
PyObject_CallFunctionObjArgs
(
s
->
parse_int
,
numstr
,
NULL
);
char
*
buf
;
/* Straight conversion to ASCII, to avoid costly conversion of
decimal unicode digits (which cannot appear here) */
n
=
idx
-
start
;
numstr
=
PyBytes_FromStringAndSize
(
NULL
,
n
);
if
(
numstr
==
NULL
)
return
NULL
;
buf
=
PyBytes_AS_STRING
(
numstr
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
buf
[
i
]
=
(
char
)
str
[
i
+
start
];
}
if
(
is_float
)
rval
=
PyFloat_FromString
(
numstr
);
else
rval
=
PyLong_FromString
(
buf
,
NULL
,
10
);
}
}
Py_DECREF
(
numstr
);
Py_DECREF
(
numstr
);
*
next_idx_ptr
=
idx
;
*
next_idx_ptr
=
idx
;
...
...
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