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
3070b71e
Unverified
Kaydet (Commit)
3070b71e
authored
Ara 25, 2017
tarafından
INADA Naoki
Kaydeden (comit)
GitHub
Ara 25, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32422: Reduce lru_cache memory usage (GH-5008)
üst
0cf16f9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
26 deletions
+8
-26
2017-12-25-20-22-47.bpo-32422.5H3Wq2.rst
...S.d/next/Library/2017-12-25-20-22-47.bpo-32422.5H3Wq2.rst
+2
-0
_functoolsmodule.c
Modules/_functoolsmodule.c
+6
-26
No files found.
Misc/NEWS.d/next/Library/2017-12-25-20-22-47.bpo-32422.5H3Wq2.rst
0 → 100644
Dosyayı görüntüle @
3070b71e
``functools.lru_cache`` uses less memory (3 words for each cached key) and
takes about 1/3 time for cyclic GC.
Modules/_functoolsmodule.c
Dosyayı görüntüle @
3070b71e
...
...
@@ -677,26 +677,9 @@ typedef struct lru_list_elem {
static
void
lru_list_elem_dealloc
(
lru_list_elem
*
link
)
{
_PyObject_GC_UNTRACK
(
link
);
Py_XDECREF
(
link
->
key
);
Py_XDECREF
(
link
->
result
);
PyObject_GC_Del
(
link
);
}
static
int
lru_list_elem_traverse
(
lru_list_elem
*
link
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
link
->
key
);
Py_VISIT
(
link
->
result
);
return
0
;
}
static
int
lru_list_elem_clear
(
lru_list_elem
*
link
)
{
Py_CLEAR
(
link
->
key
);
Py_CLEAR
(
link
->
result
);
return
0
;
PyObject_Del
(
link
);
}
static
PyTypeObject
lru_list_elem_type
=
{
...
...
@@ -720,10 +703,7 @@ static PyTypeObject lru_list_elem_type = {
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
0
,
/* tp_doc */
(
traverseproc
)
lru_list_elem_traverse
,
/* tp_traverse */
(
inquiry
)
lru_list_elem_clear
,
/* tp_clear */
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
};
...
...
@@ -959,8 +939,8 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
}
}
else
{
/* Put result in a new link at the front of the queue. */
link
=
(
lru_list_elem
*
)
PyObject_
GC_
New
(
lru_list_elem
,
&
lru_list_elem_type
);
link
=
(
lru_list_elem
*
)
PyObject_New
(
lru_list_elem
,
&
lru_list_elem_type
);
if
(
link
==
NULL
)
{
Py_DECREF
(
key
);
Py_DECREF
(
result
);
...
...
@@ -970,7 +950,6 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
link
->
hash
=
hash
;
link
->
key
=
key
;
link
->
result
=
result
;
_PyObject_GC_TRACK
(
link
);
if
(
_PyDict_SetItem_KnownHash
(
self
->
cache
,
key
,
(
PyObject
*
)
link
,
hash
)
<
0
)
{
Py_DECREF
(
link
);
...
...
@@ -1151,7 +1130,8 @@ lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg)
lru_list_elem
*
link
=
self
->
root
.
next
;
while
(
link
!=
&
self
->
root
)
{
lru_list_elem
*
next
=
link
->
next
;
Py_VISIT
(
link
);
Py_VISIT
(
link
->
key
);
Py_VISIT
(
link
->
result
);
link
=
next
;
}
Py_VISIT
(
self
->
maxsize_O
);
...
...
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