[Python-Dev] What type of object mmap.read_byte should return on py3k? (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Sat Feb 28 15:21:48 CET 2009
- Previous message: [Python-Dev] What type of object mmap.read_byte should return on py3k?
- Next message: [Python-Dev] What type of object mmap.read_byte should return on py3k?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
About m.read_byte(), we have two choices: (a) Py_BuildValue("b", value) => 0 (b) Py_BuildValue("y#", &value, 1) => b"\x00"
About m.write_byte(x), we have also two choices: (a) PyArg_ParseTuple(args, "b:write_byte", &value): write_byte(0) (b) PyArg_ParseTuple(args, "y#:write_byte", &value, &length) and check for length=1: write_byte(b"\x00")
(b) choices are close to Python 2.x API. But we can already use m.read(1)->b"\x00" and m.write(b"\x00") to use byte string of 1 byte. So it would be better to break the API and use integers, (a) choices which require also documentation changes:
mmap.read_byte() Returns a string of length 1 containing the character at the current file position, and advances the file position by 1.
mmap.write_byte(byte) Write the single-character string byte into memory at the current position of the file pointer; the file position is advanced by 1. If the mmap was created with ACCESS_READ, then writing to it will throw a TypeError exception.
-- Victor Stinner aka haypo http://www.haypocalc.com/blog/
- Previous message: [Python-Dev] What type of object mmap.read_byte should return on py3k?
- Next message: [Python-Dev] What type of object mmap.read_byte should return on py3k?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]