Message8198
A complete solution, here and many other places where a String argument really means bytes, is to accept any PyObject supporting the Buffer API. Then this would work as it does on CPython:
>>> fd = os.open('x.tmp', os.O_CREAT | os.O_RDWR)
>>> a = bytearray("Stuff and nonsense. ")
>>> os.write(fd, a)
20
>>> os.write(fd, buffer(a))
20
>>> os.write(fd, memoryview(a))
20
It would be cool to find some automagic implementation, but I think it has to be a ByteUtil class (or some such), offering few well-crafted static methods, and a re-write of these methods one by one. Asking a buffer for its String is least work but goes completely against the idea of the buffer API as efficient in-place access, unless it's really a PyString after all. |
|
Date |
User |
Action |
Args |
2013-12-14 22:40:17 | jeff.allen | set | messageid: <1387060817.72.0.198898984648.issue2062@psf.upfronthosting.co.za> |
2013-12-14 22:40:17 | jeff.allen | set | recipients:
+ jeff.allen, santa4nt, jamesls |
2013-12-14 22:40:17 | jeff.allen | link | issue2062 messages |
2013-12-14 22:40:17 | jeff.allen | create | |
|