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
03b4d507
Kaydet (Commit)
03b4d507
authored
Agu 11, 2012
tarafından
Meador Inge
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15424: Add a __sizeof__ implementation for array objects.
Patch by Ludwig Hähne.
üst
7dbee385
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
0 deletions
+32
-0
test_array.py
Lib/test/test_array.py
+13
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
arraymodule.c
Modules/arraymodule.c
+15
-0
No files found.
Lib/test/test_array.py
Dosyayı görüntüle @
03b4d507
...
@@ -988,6 +988,19 @@ class BaseTest(unittest.TestCase):
...
@@ -988,6 +988,19 @@ class BaseTest(unittest.TestCase):
a
=
array
.
array
(
'H'
,
b
"1234"
)
a
=
array
.
array
(
'H'
,
b
"1234"
)
self
.
assertEqual
(
len
(
a
)
*
a
.
itemsize
,
4
)
self
.
assertEqual
(
len
(
a
)
*
a
.
itemsize
,
4
)
@support.cpython_only
def
test_sizeof_with_buffer
(
self
):
a
=
array
.
array
(
self
.
typecode
,
self
.
example
)
basesize
=
support
.
calcvobjsize
(
'4Pi'
)
buffer_size
=
a
.
buffer_info
()[
1
]
*
a
.
itemsize
support
.
check_sizeof
(
self
,
a
,
basesize
+
buffer_size
)
@support.cpython_only
def
test_sizeof_without_buffer
(
self
):
a
=
array
.
array
(
self
.
typecode
)
basesize
=
support
.
calcvobjsize
(
'4Pi'
)
support
.
check_sizeof
(
self
,
a
,
basesize
)
class
StringTest
(
BaseTest
):
class
StringTest
(
BaseTest
):
...
...
Misc/ACKS
Dosyayı görüntüle @
03b4d507
...
@@ -434,6 +434,7 @@ Jim Hugunin
...
@@ -434,6 +434,7 @@ Jim Hugunin
Greg Humphreys
Greg Humphreys
Eric Huss
Eric Huss
Jeremy Hylton
Jeremy Hylton
Ludwig Hähne
Gerhard Häring
Gerhard Häring
Fredrik Håård
Fredrik Håård
Mihai Ibanescu
Mihai Ibanescu
...
...
Misc/NEWS
Dosyayı görüntüle @
03b4d507
...
@@ -101,6 +101,9 @@ Core and Builtins
...
@@ -101,6 +101,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #15424: Add a __sizeof__ implementation for array objects.
Patch by Ludwig Hähne.
- Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
- Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
ended with '\'. Patch by Roger Serwy.
ended with '\'. Patch by Roger Serwy.
...
...
Modules/arraymodule.c
Dosyayı görüntüle @
03b4d507
...
@@ -1510,6 +1510,19 @@ array.tobytes().decode() to obtain a unicode string from\n\
...
@@ -1510,6 +1510,19 @@ array.tobytes().decode() to obtain a unicode string from\n\
an array of some other type."
);
an array of some other type."
);
static
PyObject
*
array_sizeof
(
arrayobject
*
self
,
PyObject
*
unused
)
{
Py_ssize_t
res
;
res
=
sizeof
(
arrayobject
)
+
self
->
allocated
*
self
->
ob_descr
->
itemsize
;
return
PyLong_FromSsize_t
(
res
);
}
PyDoc_STRVAR
(
sizeof_doc
,
"__sizeof__() -> int
\n
\
\n
\
Size of the array in memory, in bytes."
);
/*********************** Pickling support ************************/
/*********************** Pickling support ************************/
...
@@ -2077,6 +2090,8 @@ static PyMethodDef array_methods[] = {
...
@@ -2077,6 +2090,8 @@ static PyMethodDef array_methods[] = {
tobytes_doc
},
tobytes_doc
},
{
"tounicode"
,
(
PyCFunction
)
array_tounicode
,
METH_NOARGS
,
{
"tounicode"
,
(
PyCFunction
)
array_tounicode
,
METH_NOARGS
,
tounicode_doc
},
tounicode_doc
},
{
"__sizeof__"
,
(
PyCFunction
)
array_sizeof
,
METH_NOARGS
,
sizeof_doc
},
{
NULL
,
NULL
}
/* sentinel */
{
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