Skip to content

use cstringio rather than += on string in libev#20

Closed
halfaleague wants to merge 2 commits intoapache:masterfrom
halfaleague:master
Closed

use cstringio rather than += on string in libev#20
halfaleague wants to merge 2 commits intoapache:masterfrom
halfaleague:master

Conversation

@halfaleague
Copy link
Copy Markdown

The current LibevConnection class is using a string variable _buf, this is used to build up a message from a socket, it is using a += to append to it, this is really slow especially when using blobs.

I have modified it to use a cStringIO and updated the tests, they all seem to run.

Use this or use it as a suggestion for an alternate implementation, thanks!

@Kami
Copy link
Copy Markdown
Member

Kami commented Sep 9, 2013

One thing to keep in mind is that in older versions of PyPy, cStringIO was a lot slower then StringIO, but with 2.0 this doesn't seem to be the case anymore so this should probably be fine.

@joaquincasares
Copy link
Copy Markdown
Contributor

Thanks for the pull request and the extra information!

I'm going to leave this open for our main Python developer to look it over and see which String builder he wants to use after all. (There will be a delay, but it won't be forgotten. :) )

@halfaleague
Copy link
Copy Markdown
Author

The main thing is fixing it, the blob usage is pretty slow otherwise. Thanks again!

@thobbs
Copy link
Copy Markdown
Contributor

thobbs commented Sep 17, 2013

Hmm, I'm seeing random hangs when running with these changes. I like the idea of using cstringio, though, so I'll dig in and see what's going on.

(By the way, it's generally a good idea to use a separate branch for pull requests instead of master so that unrelated commits don't get mixed in, like happened here. No worries, though.)

@thobbs
Copy link
Copy Markdown
Contributor

thobbs commented Sep 17, 2013

Alright, I figured out what was going on, so I went ahead and merged your changes into master along with my fixes: 445d813

Thanks!

@thobbs thobbs closed this Sep 17, 2013
@halfaleague
Copy link
Copy Markdown
Author

Thanks! This driver is very nice!

@thobbs
Copy link
Copy Markdown
Contributor

thobbs commented Sep 18, 2013

Thanks! This driver is very nice!

I'm glad you like it :)

stef1927 pushed a commit to stef1927/python-driver that referenced this pull request Mar 25, 2015
added info re: read_repair_chance and tidied up readme a little
beltran pushed a commit that referenced this pull request Mar 20, 2017
PYTHON-589 - inject client request timeout in graph custom payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants