Skip to content
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

Replace deque in StreamReader with bytearray #2971

Open
asvetlov opened this issue May 2, 2018 · 4 comments
Open

Replace deque in StreamReader with bytearray #2971

asvetlov opened this issue May 2, 2018 · 4 comments

Comments

@asvetlov
Copy link
Member

asvetlov commented May 2, 2018

bytearray is highly optimized for appending to the right and removing from the left.
On resizing it keeps up to 50% free space at the begin of buffer before performing a memory reallocation.

@spcharc
Copy link
Contributor

spcharc commented May 9, 2018

bytearray is doing a great work on appending to the right, but removing from left and resizing? I don't understand. pop(0) is the same with lists
memoryview does not support resizing either.

@asvetlov
Copy link
Member Author

asvetlov commented May 9, 2018

@spcharc it would be nice if you re-read PyByteArray_Resize implementation before posting anything.

@spcharc
Copy link
Contributor

spcharc commented May 9, 2018

@asvetlov Read the function for 2 hrs, did a lot of search, and failed to understand. I hope I can read C code one day. I won't bother you anymore then.

@serhiy-storchaka
Copy link
Contributor

See https://bugs.python.org/issue19087.

I do not know whether other implementations has such optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants