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
060ed718
Kaydet (Commit)
060ed718
authored
Ara 21, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster.
üst
22adf2ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
24 deletions
+56
-24
NEWS
Misc/NEWS
+2
-0
_elementtree.c
Modules/_elementtree.c
+54
-24
No files found.
Misc/NEWS
Dosyayı görüntüle @
060ed718
...
...
@@ -115,6 +115,8 @@ Core and Builtins
Library
-------
- Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster.
- Issue #25873: Optimized iterating ElementTree. Iterating elements
Element.iter() is now 40% faster, iterating text Element.itertext()
is now up to 2.5 times faster.
...
...
Modules/_elementtree.c
Dosyayı görüntüle @
060ed718
...
...
@@ -128,30 +128,6 @@ elementtree_free(void *m)
/* helpers */
LOCAL
(
PyObject
*
)
deepcopy
(
PyObject
*
object
,
PyObject
*
memo
)
{
/* do a deep copy of the given object */
PyObject
*
args
;
PyObject
*
result
;
elementtreestate
*
st
=
ET_STATE_GLOBAL
;
if
(
!
st
->
deepcopy_obj
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"deepcopy helper not found"
);
return
NULL
;
}
args
=
PyTuple_Pack
(
2
,
object
,
memo
);
if
(
!
args
)
return
NULL
;
result
=
PyObject_CallObject
(
st
->
deepcopy_obj
,
args
);
Py_DECREF
(
args
);
return
result
;
}
LOCAL
(
PyObject
*
)
list_join
(
PyObject
*
list
)
{
...
...
@@ -748,6 +724,9 @@ _elementtree_Element___copy___impl(ElementObject *self)
return
(
PyObject
*
)
element
;
}
/* Helper for a deep copy. */
LOCAL
(
PyObject
*
)
deepcopy
(
PyObject
*
,
PyObject
*
);
/*[clinic input]
_elementtree.Element.__deepcopy__
...
...
@@ -838,6 +817,57 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *memo)
return
NULL
;
}
LOCAL
(
PyObject
*
)
deepcopy
(
PyObject
*
object
,
PyObject
*
memo
)
{
/* do a deep copy of the given object */
PyObject
*
args
;
PyObject
*
result
;
elementtreestate
*
st
;
/* Fast paths */
if
(
object
==
Py_None
||
PyUnicode_CheckExact
(
object
))
{
Py_INCREF
(
object
);
return
object
;
}
if
(
Py_REFCNT
(
object
)
==
1
)
{
if
(
PyDict_CheckExact
(
object
))
{
PyObject
*
key
,
*
value
;
Py_ssize_t
pos
=
0
;
int
simple
=
1
;
while
(
PyDict_Next
(
object
,
&
pos
,
&
key
,
&
value
))
{
if
(
!
PyUnicode_CheckExact
(
key
)
||
!
PyUnicode_CheckExact
(
value
))
{
simple
=
0
;
break
;
}
}
if
(
simple
)
return
PyDict_Copy
(
object
);
/* Fall through to general case */
}
else
if
(
Element_CheckExact
(
object
))
{
return
_elementtree_Element___deepcopy__
((
ElementObject
*
)
object
,
memo
);
}
}
/* General case */
st
=
ET_STATE_GLOBAL
;
if
(
!
st
->
deepcopy_obj
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"deepcopy helper not found"
);
return
NULL
;
}
args
=
PyTuple_Pack
(
2
,
object
,
memo
);
if
(
!
args
)
return
NULL
;
result
=
PyObject_CallObject
(
st
->
deepcopy_obj
,
args
);
Py_DECREF
(
args
);
return
result
;
}
/*[clinic input]
_elementtree.Element.__sizeof__ -> Py_ssize_t
...
...
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