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.

Author pitrou
Recipients pitrou, pv
Date 2010-09-12.13:47:24
SpamBayes Score 2.385931e-07
Marked as misclassified No
Message-id <1284299246.57.0.843557049419.issue9838@psf.upfronthosting.co.za>
In-reply-to
Content
> Instead, every call must go through PyObject_CallMethod, and the file
> objects only handle `PyBytes` and `PyByteArray` which are cumbersome
> and inefficient to use in extension modules.

Because of the generic nature of the 3.x I/O stack, even shortcuts such as the proposed PyFile_Write will still have to use PyObject_CallMethod(obj, "write", ...) under the hood.

As for the types handled by file objects, you should be able to use a PyMemoryViewObject, which allows you to create a memory buffer without copying it (if that's what you're after).
You can also pass your own objects provided they support the new buffer API: http://docs.python.org/dev/c-api/buffer.html#bufferobjects
(I agree this documentation is not very well written, though)

So, bottom line, we could create a set of PyFile_* wrappers (or, rather, PyStream_*), but they wouldn't be much more efficient that what you can write by hand. Do you still think it's worth it? If so, I think you should float the idea on python-dev (the mailing-list).
History
Date User Action Args
2010-09-12 13:47:26pitrousetrecipients: + pitrou, pv
2010-09-12 13:47:26pitrousetmessageid: <1284299246.57.0.843557049419.issue9838@psf.upfronthosting.co.za>
2010-09-12 13:47:24pitroulinkissue9838 messages
2010-09-12 13:47:24pitroucreate