Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a3f4457b
Commit
a3f4457b
authored
Apr 17, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up reading of small files. This avoids multiple C read() calls on pyc files.
parent
006917ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
Modules/_io/fileio.c
Modules/_io/fileio.c
+11
-3
No files found.
Modules/_io/fileio.c
View file @
a3f4457b
...
...
@@ -572,6 +572,7 @@ new_buffersize(fileio *self, size_t currentsize
#endif
)
{
size_t
addend
;
#ifdef HAVE_FSTAT
if
(
end
!=
(
Py_off_t
)
-
1
)
{
/* Files claiming a size smaller than SMALLCHUNK may
...
...
@@ -589,9 +590,16 @@ new_buffersize(fileio *self, size_t currentsize
}
#endif
/* Expand the buffer by an amount proportional to the current size,
giving us amortized linear-time behavior. Use a less-than-double
growth factor to avoid excessive allocation. */
return
currentsize
+
(
currentsize
>>
3
)
+
6
;
giving us amortized linear-time behavior. For bigger sizes, use a
less-than-double growth factor to avoid excessive allocation. */
if
(
currentsize
>
65536
)
addend
=
currentsize
>>
3
;
else
addend
=
256
+
currentsize
;
if
(
addend
<
SMALLCHUNK
)
/* Avoid tiny read() calls. */
addend
=
SMALLCHUNK
;
return
addend
+
currentsize
;
}
static
PyObject
*
...
...
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