[Python-Dev] file.readinto performance regression in Python 3.2 vs. 2.7?

Antoine Pitrou solipsis at pitrou.net
Fri Nov 25 02:07:00 CET 2011


On Fri, 25 Nov 2011 12:02:17 +1100
Matt Joiner <anacrolix at gmail.com> wrote:
> It's my impression that the readinto method does not fully support the
> buffer interface I was expecting. I've never had cause to use it until
> now. I've created a question on SO that describes my confusion:
> 
> http://stackoverflow.com/q/8263899/149482

Just use a memoryview and slice it:

b = bytearray(...)
m = memoryview(b)
n = f.readinto(m[some_offset:])

> Also I saw some comments on "top-posting" am I guilty of this?

Kind of :)

Regards

Antoine.




More information about the Python-Dev mailing list