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
48c70344
Kaydet (Commit)
48c70344
authored
Agu 09, 2001
tarafından
Neil Schemenauer
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add get_referents function. Closes SF patch #402925.
üst
dbdcb0fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
gcmodule.c
Modules/gcmodule.c
+50
-0
No files found.
Modules/gcmodule.c
Dosyayı görüntüle @
48c70344
...
...
@@ -677,6 +677,53 @@ gc_get_thresh(PyObject *self, PyObject *args)
return
Py_BuildValue
(
"(iii)"
,
threshold0
,
threshold1
,
threshold2
);
}
struct
referents
{
PyObject
*
objs
;
int
seen
;
};
static
int
referentsvisit
(
PyObject
*
obj
,
struct
referents
*
refs
)
{
if
(
PySequence_Contains
(
refs
->
objs
,
obj
))
{
refs
->
seen
=
1
;
return
1
;
}
return
0
;
}
static
void
gc_referents_for
(
PyObject
*
objs
,
PyGC_Head
*
list
,
PyObject
*
resultlist
)
{
PyGC_Head
*
gc
;
PyObject
*
obj
;
traverseproc
traverse
;
struct
referents
refs
=
{
objs
,
0
};
for
(
gc
=
list
->
gc_next
;
gc
!=
list
;
gc
=
gc
->
gc_next
){
obj
=
PyObject_FROM_GC
(
gc
);
traverse
=
obj
->
ob_type
->
tp_traverse
;
if
(
obj
==
objs
||
obj
==
resultlist
)
continue
;
if
(
traverse
(
obj
,
(
visitproc
)
referentsvisit
,
&
refs
))
{
PyList_Append
(
resultlist
,
obj
);
refs
.
seen
=
0
;
}
}
}
static
char
gc_get_referents__doc__
[]
=
"get_referents(*objs) -> list
\n
\
Return the list of objects that directly refer to any of objs."
;
static
PyObject
*
gc_get_referents
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
result
=
PyList_New
(
0
);
gc_referents_for
(
args
,
&
generation0
,
result
);
gc_referents_for
(
args
,
&
generation1
,
result
);
gc_referents_for
(
args
,
&
generation2
,
result
);
return
result
;
}
static
char
gc__doc__
[]
=
"This module provides access to the garbage collector for reference cycles.
\n
"
...
...
@@ -689,6 +736,7 @@ static char gc__doc__ [] =
"get_debug() -- Get debugging flags.
\n
"
"set_threshold() -- Set the collection thresholds.
\n
"
"get_threshold() -- Return the current the collection thresholds.
\n
"
"get_referents() -- Return the list of objects that refer to an object.
\n
"
;
static
PyMethodDef
GcMethods
[]
=
{
...
...
@@ -700,6 +748,8 @@ static PyMethodDef GcMethods[] = {
{
"set_threshold"
,
gc_set_thresh
,
METH_VARARGS
,
gc_set_thresh__doc__
},
{
"get_threshold"
,
gc_get_thresh
,
METH_VARARGS
,
gc_get_thresh__doc__
},
{
"collect"
,
gc_collect
,
METH_VARARGS
,
gc_collect__doc__
},
{
"get_referents"
,
gc_get_referents
,
METH_VARARGS
,
gc_get_referents__doc__
},
{
NULL
,
NULL
}
/* Sentinel */
};
...
...
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