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
547d3bc3
Kaydet (Commit)
547d3bc3
authored
Agu 14, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #22193: Added private function _PySys_GetSizeOf() needed to implement
some __sizeof__() methods.
üst
143fe05d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
32 deletions
+44
-32
sysmodule.h
Include/sysmodule.h
+4
-0
sysmodule.c
Python/sysmodule.c
+40
-32
No files found.
Include/sysmodule.h
Dosyayı görüntüle @
547d3bc3
...
...
@@ -33,6 +33,10 @@ PyAPI_FUNC(int) PySys_HasWarnOptions(void);
PyAPI_FUNC
(
void
)
PySys_AddXOption
(
const
wchar_t
*
);
PyAPI_FUNC
(
PyObject
*
)
PySys_GetXOptions
(
void
);
#ifndef Py_LIMITED_API
PyAPI_DATA
(
size_t
)
_PySys_GetSizeOf
(
PyObject
*
);
#endif
#ifdef __cplusplus
}
#endif
...
...
Python/sysmodule.c
Dosyayı görüntüle @
547d3bc3
...
...
@@ -863,29 +863,16 @@ sys_mdebug(PyObject *self, PyObject *args)
}
#endif
/* USE_MALLOPT */
s
tatic
PyObject
*
sys_getsizeof
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
s
ize_t
_PySys_GetSizeOf
(
PyObject
*
o
)
{
PyObject
*
res
=
NULL
;
static
PyObject
*
gc_head_size
=
NULL
;
static
char
*
kwlist
[]
=
{
"object"
,
"default"
,
0
};
PyObject
*
o
,
*
dflt
=
NULL
;
PyObject
*
method
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O|O:getsizeof"
,
kwlist
,
&
o
,
&
dflt
))
return
NULL
;
/* Initialize static variable for GC head size */
if
(
gc_head_size
==
NULL
)
{
gc_head_size
=
PyLong_FromSsize_t
(
sizeof
(
PyGC_Head
));
if
(
gc_head_size
==
NULL
)
return
NULL
;
}
size_t
size
;
/* Make sure the type is initialized. float gets initialized late */
if
(
PyType_Ready
(
Py_TYPE
(
o
))
<
0
)
return
NULL
;
return
(
size_t
)
-
1
;
method
=
_PyObject_LookupSpecial
(
o
,
&
PyId___sizeof__
);
if
(
method
==
NULL
)
{
...
...
@@ -899,24 +886,45 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds)
Py_DECREF
(
method
);
}
/* Has a default value been given */
if
((
res
==
NULL
)
&&
(
dflt
!=
NULL
)
&&
PyErr_ExceptionMatches
(
PyExc_TypeError
))
{
PyErr_Clear
();
Py_INCREF
(
dflt
);
return
dflt
;
}
else
if
(
res
==
NULL
)
return
res
;
if
(
res
==
NULL
)
return
(
size_t
)
-
1
;
size
=
PyLong_AsSize_t
(
res
);
Py_DECREF
(
res
);
if
(
size
==
(
size_t
)
-
1
&&
PyErr_Occurred
())
return
(
size_t
)
-
1
;
/* add gc_head size */
if
(
PyObject_IS_GC
(
o
))
{
PyObject
*
tmp
=
res
;
res
=
PyNumber_Add
(
tmp
,
gc_head_size
);
Py_DECREF
(
tmp
);
if
(
PyObject_IS_GC
(
o
))
size
+=
sizeof
(
PyGC_Head
);
return
size
;
}
static
PyObject
*
sys_getsizeof
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
static
char
*
kwlist
[]
=
{
"object"
,
"default"
,
0
};
size_t
size
;
PyObject
*
o
,
*
dflt
=
NULL
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O|O:getsizeof"
,
kwlist
,
&
o
,
&
dflt
))
return
NULL
;
size
=
_PySys_GetSizeOf
(
o
);
if
(
size
==
(
size_t
)
-
1
&&
PyErr_Occurred
())
{
/* Has a default value been given */
if
(
dflt
!=
NULL
&&
PyErr_ExceptionMatches
(
PyExc_TypeError
))
{
PyErr_Clear
();
Py_INCREF
(
dflt
);
return
dflt
;
}
else
return
NULL
;
}
return
res
;
return
PyLong_FromSize_t
(
size
);
}
PyDoc_STRVAR
(
getsizeof_doc
,
...
...
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