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
10f0c50a
Kaydet (Commit)
10f0c50a
authored
Tem 29, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
Patch by Serhiy Storchaka.
üst
33f79972
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
test_io.py
Lib/test/test_io.py
+17
-3
NEWS
Misc/NEWS
+3
-0
bufferedio.c
Modules/_io/bufferedio.c
+14
-0
No files found.
Lib/test/test_io.py
Dosyayı görüntüle @
10f0c50a
...
@@ -792,6 +792,20 @@ class CommonBufferedTests:
...
@@ -792,6 +792,20 @@ class CommonBufferedTests:
buf
.
raw
=
x
buf
.
raw
=
x
class
SizeofTest
:
@support.cpython_only
def
test_sizeof
(
self
):
bufsize1
=
4096
bufsize2
=
8192
rawio
=
self
.
MockRawIO
()
bufio
=
self
.
tp
(
rawio
,
buffer_size
=
bufsize1
)
size
=
sys
.
getsizeof
(
bufio
)
-
bufsize1
rawio
=
self
.
MockRawIO
()
bufio
=
self
.
tp
(
rawio
,
buffer_size
=
bufsize2
)
self
.
assertEqual
(
sys
.
getsizeof
(
bufio
),
size
+
bufsize2
)
class
BufferedReaderTest
(
unittest
.
TestCase
,
CommonBufferedTests
):
class
BufferedReaderTest
(
unittest
.
TestCase
,
CommonBufferedTests
):
read_mode
=
"rb"
read_mode
=
"rb"
...
@@ -983,7 +997,7 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
...
@@ -983,7 +997,7 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
"failed for {}: {} != 0"
.
format
(
n
,
rawio
.
_extraneous_reads
))
"failed for {}: {} != 0"
.
format
(
n
,
rawio
.
_extraneous_reads
))
class
CBufferedReaderTest
(
BufferedReaderTest
):
class
CBufferedReaderTest
(
BufferedReaderTest
,
SizeofTest
):
tp
=
io
.
BufferedReader
tp
=
io
.
BufferedReader
def
test_constructor
(
self
):
def
test_constructor
(
self
):
...
@@ -1245,7 +1259,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
...
@@ -1245,7 +1259,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
self
.
tp
(
self
.
MockRawIO
(),
8
,
12
)
self
.
tp
(
self
.
MockRawIO
(),
8
,
12
)
class
CBufferedWriterTest
(
BufferedWriterTest
):
class
CBufferedWriterTest
(
BufferedWriterTest
,
SizeofTest
):
tp
=
io
.
BufferedWriter
tp
=
io
.
BufferedWriter
def
test_constructor
(
self
):
def
test_constructor
(
self
):
...
@@ -1636,7 +1650,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
...
@@ -1636,7 +1650,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
# You can't construct a BufferedRandom over a non-seekable stream.
# You can't construct a BufferedRandom over a non-seekable stream.
test_unseekable
=
None
test_unseekable
=
None
class
CBufferedRandomTest
(
BufferedRandomTest
):
class
CBufferedRandomTest
(
BufferedRandomTest
,
SizeofTest
):
tp
=
io
.
BufferedRandom
tp
=
io
.
BufferedRandom
def
test_constructor
(
self
):
def
test_constructor
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
10f0c50a
...
@@ -98,6 +98,9 @@ Core and Builtins
...
@@ -98,6 +98,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
Patch by Serhiy Storchaka.
- Issue #6056: Make multiprocessing use setblocking(True) on the
- Issue #6056: Make multiprocessing use setblocking(True) on the
sockets it uses. Original patch by J Derek Wilson.
sockets it uses. Original patch by J Derek Wilson.
...
...
Modules/_io/bufferedio.c
Dosyayı görüntüle @
10f0c50a
...
@@ -383,6 +383,17 @@ buffered_dealloc(buffered *self)
...
@@ -383,6 +383,17 @@ buffered_dealloc(buffered *self)
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
}
}
static
PyObject
*
buffered_sizeof
(
buffered
*
self
,
void
*
unused
)
{
Py_ssize_t
res
;
res
=
sizeof
(
buffered
);
if
(
self
->
buffer
)
res
+=
self
->
buffer_size
;
return
PyLong_FromSsize_t
(
res
);
}
static
int
static
int
buffered_traverse
(
buffered
*
self
,
visitproc
visit
,
void
*
arg
)
buffered_traverse
(
buffered
*
self
,
visitproc
visit
,
void
*
arg
)
{
{
...
@@ -1591,6 +1602,7 @@ static PyMethodDef bufferedreader_methods[] = {
...
@@ -1591,6 +1602,7 @@ static PyMethodDef bufferedreader_methods[] = {
{
"seek"
,
(
PyCFunction
)
buffered_seek
,
METH_VARARGS
},
{
"seek"
,
(
PyCFunction
)
buffered_seek
,
METH_VARARGS
},
{
"tell"
,
(
PyCFunction
)
buffered_tell
,
METH_NOARGS
},
{
"tell"
,
(
PyCFunction
)
buffered_tell
,
METH_NOARGS
},
{
"truncate"
,
(
PyCFunction
)
buffered_truncate
,
METH_VARARGS
},
{
"truncate"
,
(
PyCFunction
)
buffered_truncate
,
METH_VARARGS
},
{
"__sizeof__"
,
(
PyCFunction
)
buffered_sizeof
,
METH_NOARGS
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -1985,6 +1997,7 @@ static PyMethodDef bufferedwriter_methods[] = {
...
@@ -1985,6 +1997,7 @@ static PyMethodDef bufferedwriter_methods[] = {
{
"flush"
,
(
PyCFunction
)
buffered_flush
,
METH_NOARGS
},
{
"flush"
,
(
PyCFunction
)
buffered_flush
,
METH_NOARGS
},
{
"seek"
,
(
PyCFunction
)
buffered_seek
,
METH_VARARGS
},
{
"seek"
,
(
PyCFunction
)
buffered_seek
,
METH_VARARGS
},
{
"tell"
,
(
PyCFunction
)
buffered_tell
,
METH_NOARGS
},
{
"tell"
,
(
PyCFunction
)
buffered_tell
,
METH_NOARGS
},
{
"__sizeof__"
,
(
PyCFunction
)
buffered_sizeof
,
METH_NOARGS
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -2384,6 +2397,7 @@ static PyMethodDef bufferedrandom_methods[] = {
...
@@ -2384,6 +2397,7 @@ static PyMethodDef bufferedrandom_methods[] = {
{
"readline"
,
(
PyCFunction
)
buffered_readline
,
METH_VARARGS
},
{
"readline"
,
(
PyCFunction
)
buffered_readline
,
METH_VARARGS
},
{
"peek"
,
(
PyCFunction
)
buffered_peek
,
METH_VARARGS
},
{
"peek"
,
(
PyCFunction
)
buffered_peek
,
METH_VARARGS
},
{
"write"
,
(
PyCFunction
)
bufferedwriter_write
,
METH_VARARGS
},
{
"write"
,
(
PyCFunction
)
bufferedwriter_write
,
METH_VARARGS
},
{
"__sizeof__"
,
(
PyCFunction
)
buffered_sizeof
,
METH_NOARGS
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
...
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