Author nikratio
Recipients benjamin.peterson, hynek, loewis, nikratio, pitrou, stutzbach, vstinner
Date 2014-04-14.01:58:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397440699.57.0.98610155682.issue20578@psf.upfronthosting.co.za>
In-reply-to
Content
Here's a little script to estimate the performance difference between using read1 and readinto1 to read large amounts of data. On my system, I get:

C readinto1: 4.960e-01 seconds
C read1: 4.055e-01 seconds
Python readinto1: 1.066e+00 seconds
Python read1: 2.565e+00 seconds

In other words, _pyio.BufferedReader.readinto1 is more than a factor of 2 faster than _pyio.BufferedReader.read1 and io.readinto1 is faster than io.read1 by about 20%.


On its own, I think this would justify keeping an implementation of readinto1 in _pyio.BufferedReader instead of falling back on the default (that is implemented using read1). However, I believe that people who need performance are probably not using _pyio but io, so *my* argument for keeping it implemented in _pyio is to keep the implementations similiar.

I found studying _pyio very helpful to understand the C code in io. If we implement BufferedReader.readinto1 in io, but not in _pyio.BufferedReader, this advantage would be reduced.


That said, I am primary interested in getting readinto1 into io. So I'm happy to either extend the patch to also provide a fast readinto implementation for _pyio (to align it with io), or to remove the readinto1 implementation in _pyio.
History
Date User Action Args
2014-04-14 01:58:19nikratiosetrecipients: + nikratio, loewis, pitrou, vstinner, benjamin.peterson, stutzbach, hynek
2014-04-14 01:58:19nikratiosetmessageid: <1397440699.57.0.98610155682.issue20578@psf.upfronthosting.co.za>
2014-04-14 01:58:19nikratiolinkissue20578 messages
2014-04-14 01:58:18nikratiocreate