[Python-ideas] Addition to I/O stack: send()
Antoine Pitrou
solipsis at pitrou.net
Sun Apr 19 02:35:00 CEST 2009
Hello again,
> Right now, it is true there is no way to do this kind of things. There are two
> distinct things you are asking for really:
> 1/ direct access to the buffered data of a BufferedIOBase object without
copying
> things around
We could add two methods to BufferedIOBase:
- peek_inside(self[, n]): returns a view of up to n bytes on the internal buffer
- read_inside(self[, n]): same as peek_inside(), but also advances the file
position after the end of the returned view
The good thing is that default unoptimized versions of these methods could be
provided in the BufferedIOBase ABC, simply by calling peek() (resp. read()) and
wrapping the result in a memoryview.
Regards
Antoine.
More information about the Python-ideas
mailing list