This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix O(n**2) performance problem in socket._fileobject
Type: performance Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: amaury.forgeotdarc, georg.brandl, gregory.p.smith, kristjan.jonsson
Priority: normal Keywords: easy, needs review, patch

Created on 2009-05-26 16:03 by kristjan.jonsson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
socket.patch kristjan.jonsson, 2009-05-26 16:03
Messages (6)
msg88366 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-05-26 16:03
the socket._fileobject._wbuf is a list of strings to output.  This patch 
keeps the length of this buffer as a separate member variable, rather than  
computing it dynamically, which sums to a O(n**2) operation as the buffer 
is filled up.  Significant performance degradation was observed when 
outputting lots of small data to a buffered socket using the old method.
msg88372 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-05-26 16:39
The patch looks good to me.
Be careful for the 3.0 port: filter() returns an iterator.
msg88374 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-05-26 16:44
the filter() is rendundant, really.  There is no reason to drop those 
empty strings at this stage.
msg88741 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-06-02 13:24
Checked into trunk as r73145
msg89787 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-06-28 21:12
There is no need to port this to 3.2, it uses a completely different IO 
system for socket fileobjects.
msg91596 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2009-08-15 06:41
backported to release26-maint in r74456.
History
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50367
2009-08-15 06:41:04gregory.p.smithsetkeywords: patch, patch, easy, needs review
nosy: + gregory.p.smith
messages: + msg91596

2009-06-28 21:12:49kristjan.jonssonsetkeywords: patch, patch, easy, needs review

messages: + msg89787
2009-06-02 13:27:22kristjan.jonssonsetstatus: open -> closed
keywords: patch, patch, easy, needs review
stage: resolved
2009-06-02 13:24:46kristjan.jonssonsetassignee: georg.brandl
components: + Documentation

keywords: patch, patch, easy, needs review
nosy: + georg.brandl
messages: + msg88741
resolution: accepted
2009-05-26 16:44:41kristjan.jonssonsetkeywords: patch, patch, easy, needs review

messages: + msg88374
2009-05-26 16:39:40amaury.forgeotdarcsetkeywords: patch, patch, easy, needs review
nosy: + amaury.forgeotdarc
messages: + msg88372

2009-05-26 16:03:58kristjan.jonssoncreate