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
a872de55
Kaydet (Commit)
a872de55
authored
Ara 05, 2008
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed issue #4533: File read operation was dreadfully slow
üst
7a259ca8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
NEWS
Misc/NEWS
+4
-0
_fileio.c
Modules/_fileio.c
+27
-4
No files found.
Misc/NEWS
Dosyayı görüntüle @
a872de55
...
...
@@ -12,6 +12,10 @@ What's New in Python 3.1 alpha 0
Core and Builtins
-----------------
- Issue #4533: File read operation was dreadfully slow due to a slowly
growing read buffer. Fixed by using the same growth rate algorithm as
Python 2.x.
Library
-------
...
...
Modules/_fileio.c
Dosyayı görüntüle @
a872de55
...
...
@@ -27,6 +27,20 @@
#include <windows.h>
#endif
#if BUFSIZ < (8*1024)
#define SMALLCHUNK (8*1024)
#elif (BUFSIZ >= (2 << 25))
#error "unreasonable BUFSIZ > 64MB defined"
#else
#define SMALLCHUNK BUFSIZ
#endif
#if SIZEOF_INT < 4
#define BIGCHUNK (512 * 32)
#else
#define BIGCHUNK (512 * 1024)
#endif
typedef
struct
{
PyObject_HEAD
int
fd
;
...
...
@@ -387,8 +401,6 @@ fileio_readinto(PyFileIOObject *self, PyObject *args)
return
PyLong_FromSsize_t
(
n
);
}
#define DEFAULT_BUFFER_SIZE (8*1024)
static
PyObject
*
fileio_readall
(
PyFileIOObject
*
self
)
{
...
...
@@ -396,12 +408,23 @@ fileio_readall(PyFileIOObject *self)
Py_ssize_t
total
=
0
;
int
n
;
result
=
PyBytes_FromStringAndSize
(
NULL
,
DEFAULT_BUFFER_SIZE
);
result
=
PyBytes_FromStringAndSize
(
NULL
,
SMALLCHUNK
);
if
(
result
==
NULL
)
return
NULL
;
while
(
1
)
{
Py_ssize_t
newsize
=
total
+
DEFAULT_BUFFER_SIZE
;
Py_ssize_t
newsize
=
(
total
<
SMALLCHUNK
)
?
SMALLCHUNK
:
total
;
/* Keep doubling until we reach BIGCHUNK;
then keep adding BIGCHUNK. */
if
(
newsize
<=
BIGCHUNK
)
{
newsize
+=
newsize
;
}
else
{
/* NOTE: overflow impossible due to limits on BUFSIZ */
newsize
+=
BIGCHUNK
;
}
if
(
PyBytes_GET_SIZE
(
result
)
<
newsize
)
{
if
(
_PyBytes_Resize
(
&
result
,
newsize
)
<
0
)
{
if
(
total
==
0
)
{
...
...
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