[Python-Dev] Regarding stdlib socket module, _fileobject.flush() method using ._rbufsize instead of ._wbufsize (original) (raw)
Peter Portante peter.a.portante at gmail.com
Wed Oct 16 23:01:18 CEST 2013
- Previous message: [Python-Dev] Making submodules available when importing top one
- Next message: [Python-Dev] Regarding stdlib socket module, _fileobject.flush() method using ._rbufsize instead of ._wbufsize
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
Is there a reason why the stdlib socket module _fileobject.flush() method is using ._rbufsize instead of ._wbufsize at line 297 (Python 2.7.3), where it determines the buffer_size value to be used for _sock.sendall()? Does anybody know the history behind this?
Based on what I read in the code, there appear to be four code paths possible setting the _rbufsize and _wbufsize when creating an _fileobject:
default, or negative, bufsize argument
bufsize argument is set to the default_bufsize class attribute _rbufsize = bufsize _wbufsize = bufsize
bufsize = 0
_rbufsize = 1 _wbufsize = 0
bufsize = 1
_rbufsize = default_bufsize class attribute _wbufsize = 1
bufsize > 1
_rbufsize = _wbufsize = bufsize
With that, write() and writelines() uses _wbufsize, as expected.
Additionally, could flush's buffer_size local variable be determined just the same using:
buffer_size = max(self._wbufsize, self.bufsize)
Thanks for considering.
-peter -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20131016/b78882a9/attachment.html>
- Previous message: [Python-Dev] Making submodules available when importing top one
- Next message: [Python-Dev] Regarding stdlib socket module, _fileobject.flush() method using ._rbufsize instead of ._wbufsize
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]