[Python-Dev] What type of object mmap.read_byte should return on py3k? (original) (raw)

Hirokazu Yamamoto ocean-city at m2.ccsnet.ne.jp
Sat Feb 28 16:23:28 CET 2009


Victor Stinner wrote:

About m.readbyte(), we have two choices: (a) PyBuildValue("b", value) => 0 (b) PyBuildValue("y#", &value, 1) => b"\x00"

About m.writebyte(x), we have also two choices: (a) PyArgParseTuple(args, "b:writebyte", &value): writebyte(0) (b) PyArgParseTuple(args, "y#:writebyte", &value, &length) and check for length=1: writebyte(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:

I'm +1 for (a) because mmap.getitem already returns integer not 1-length bytes. And as I wrote in http://bugs.python.org/msg82912, it seems that more bytes cleanup is needed in mmap documentaion/implementation. I hope someone else will look into other modules' ones. ;-)



More information about the Python-Dev mailing list