New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_io.FileIO uses a quadratic-time buffer growth algorithm #57368
Comments
As mentioned in bpo-6715, the buffer growth strategy used by _io.FileIO if (currentsize > SMALLCHUNK) {
/* Keep doubling until we reach BIGCHUNK;
then keep adding BIGCHUNK. */
if (currentsize <= BIGCHUNK)
return currentsize + currentsize;
else
return currentsize + BIGCHUNK;
}
return currentsize + SMALLCHUNK; Is there a reason for this? One possible improvement would be to instead new_allocated = (newsize >> 3) + (newsize < 9 ? 3 : 6); which has amortized O(n) running time behaviour. Your thoughts? |
I've attached a patch that makes the suggested change to FileIO, and also |
The patch looks good to me, thanks. |
New changeset d18c80a8c119 by Nadeem Vawda in branch '3.2': New changeset 4a6709a071d0 by Nadeem Vawda in branch 'default': |
New changeset c1c434e30e06 by Nadeem Vawda in branch '2.7': |
Thank you :) |
No problem :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: