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
730f5535
Kaydet (Commit)
730f5535
authored
Nis 08, 2003
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
s/referrents/referents/g. Gotta love that referrers remains rife with rs.
üst
0f81ab6d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
libgc.tex
Doc/lib/libgc.tex
+2
-2
test_gc.py
Lib/test/test_gc.py
+11
-11
NEWS
Misc/NEWS
+1
-1
gcmodule.c
Modules/gcmodule.c
+8
-8
No files found.
Doc/lib/libgc.tex
Dosyayı görüntüle @
730f5535
...
...
@@ -99,9 +99,9 @@ objects, call \function{collect()} before calling
\versionadded
{
2.2
}
\end{funcdesc}
\begin{funcdesc}
{
get
_
refer
r
ents
}{
*objs
}
\begin{funcdesc}
{
get
_
referents
}{
*objs
}
Return a list of objects directly referred to by any of the arguments.
The refer
r
ents returned are those objects visited by the arguments'
The referents returned are those objects visited by the arguments'
C-level
\cfunction
{
tp
_
traverse
}
methods (if any), and may not be all
objects actually directly reachable.
\cfunction
{
tp
_
traverse
}
methods
are supported only by objects that support garbage collection, and are
...
...
Lib/test/test_gc.py
Dosyayı görüntüle @
730f5535
...
...
@@ -304,28 +304,28 @@ def test_boom2():
expect
(
gc
.
collect
(),
4
,
"boom2"
)
expect
(
len
(
gc
.
garbage
),
garbagelen
,
"boom2"
)
def
test_get_refer
r
ents
():
def
test_get_referents
():
alist
=
[
1
,
3
,
5
]
got
=
gc
.
get_refer
r
ents
(
alist
)
got
=
gc
.
get_referents
(
alist
)
got
.
sort
()
expect
(
got
,
alist
,
"get_refer
r
ents"
)
expect
(
got
,
alist
,
"get_referents"
)
atuple
=
tuple
(
alist
)
got
=
gc
.
get_refer
r
ents
(
atuple
)
got
=
gc
.
get_referents
(
atuple
)
got
.
sort
()
expect
(
got
,
alist
,
"get_refer
r
ents"
)
expect
(
got
,
alist
,
"get_referents"
)
adict
=
{
1
:
3
,
5
:
7
}
expected
=
[
1
,
3
,
5
,
7
]
got
=
gc
.
get_refer
r
ents
(
adict
)
got
=
gc
.
get_referents
(
adict
)
got
.
sort
()
expect
(
got
,
expected
,
"get_refer
r
ents"
)
expect
(
got
,
expected
,
"get_referents"
)
got
=
gc
.
get_refer
r
ents
([
1
,
2
],
{
3
:
4
},
(
0
,
0
,
0
))
got
=
gc
.
get_referents
([
1
,
2
],
{
3
:
4
},
(
0
,
0
,
0
))
got
.
sort
()
expect
(
got
,
[
0
,
0
]
+
range
(
5
),
"get_refer
r
ents"
)
expect
(
got
,
[
0
,
0
]
+
range
(
5
),
"get_referents"
)
expect
(
gc
.
get_refer
rents
(
1
,
'a'
,
4
j
),
[],
"get_refer
rents"
)
expect
(
gc
.
get_refer
ents
(
1
,
'a'
,
4
j
),
[],
"get_refe
rents"
)
def
test_all
():
gc
.
collect
()
# Delete 2nd generation garbage
...
...
@@ -347,7 +347,7 @@ def test_all():
run_test
(
"trashcan"
,
test_trashcan
)
run_test
(
"boom"
,
test_boom
)
run_test
(
"boom2"
,
test_boom2
)
run_test
(
"get_refer
rents"
,
test_get_refer
rents
)
run_test
(
"get_refer
ents"
,
test_get_refe
rents
)
def
test
():
if
verbose
:
...
...
Misc/NEWS
Dosyayı görüntüle @
730f5535
...
...
@@ -49,7 +49,7 @@ Core and builtins
Extension modules
-----------------
- New function gc.get_refer
r
ents(obj) returns a list of objects
- New function gc.get_referents(obj) returns a list of objects
directly referenced by obj. In effect, it exposes what the object'
s
tp_traverse
slot
does
,
and
can
be
helpful
when
debugging
memory
leaks
.
...
...
Modules/gcmodule.c
Dosyayı görüntüle @
730f5535
...
...
@@ -859,17 +859,17 @@ gc_get_referrers(PyObject *self, PyObject *args)
/* Append obj to list; return true if error (out of memory), false if OK. */
static
int
refer
r
entsvisit
(
PyObject
*
obj
,
PyObject
*
list
)
referentsvisit
(
PyObject
*
obj
,
PyObject
*
list
)
{
return
PyList_Append
(
list
,
obj
)
<
0
;
}
PyDoc_STRVAR
(
gc_get_refer
r
ents__doc__
,
"get_refer
r
ents(*objs) -> list
\n
\
PyDoc_STRVAR
(
gc_get_referents__doc__
,
"get_referents(*objs) -> list
\n
\
Return the list of objects that are directly referred to by objs."
);
static
PyObject
*
gc_get_refer
r
ents
(
PyObject
*
self
,
PyObject
*
args
)
gc_get_referents
(
PyObject
*
self
,
PyObject
*
args
)
{
int
i
;
PyObject
*
result
=
PyList_New
(
0
);
...
...
@@ -886,7 +886,7 @@ gc_get_referrents(PyObject *self, PyObject *args)
traverse
=
obj
->
ob_type
->
tp_traverse
;
if
(
!
traverse
)
continue
;
if
(
traverse
(
obj
,
(
visitproc
)
refer
r
entsvisit
,
result
))
{
if
(
traverse
(
obj
,
(
visitproc
)
referentsvisit
,
result
))
{
Py_DECREF
(
result
);
return
NULL
;
}
...
...
@@ -932,7 +932,7 @@ PyDoc_STRVAR(gc__doc__,
"get_threshold() -- Return the current the collection thresholds.
\n
"
"get_objects() -- Return a list of all objects tracked by the collector.
\n
"
"get_referrers() -- Return the list of objects that refer to an object.
\n
"
"get_refer
r
ents() -- Return the list of objects that an object refers to.
\n
"
);
"get_referents() -- Return the list of objects that an object refers to.
\n
"
);
static
PyMethodDef
GcMethods
[]
=
{
{
"enable"
,
gc_enable
,
METH_NOARGS
,
gc_enable__doc__
},
...
...
@@ -946,8 +946,8 @@ static PyMethodDef GcMethods[] = {
{
"get_objects"
,
gc_get_objects
,
METH_NOARGS
,
gc_get_objects__doc__
},
{
"get_referrers"
,
gc_get_referrers
,
METH_VARARGS
,
gc_get_referrers__doc__
},
{
"get_refer
rents"
,
gc_get_refer
rents
,
METH_VARARGS
,
gc_get_refer
r
ents__doc__
},
{
"get_refer
ents"
,
gc_get_refe
rents
,
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