[Python-Dev] Convert int() to size_t in Python/C

Random832 random832 at fastmail.com
Fri Apr 29 14:25:31 EDT 2016


On Fri, Apr 29, 2016, at 14:11, Marcos Dione wrote:
>     These are not output parameters, even if they're pointers. they'r
> using the NULL pointer to signal that the current offsets should not be
> touched, to differentiate from a offset of 0. Something that in Python we
> would use None.

That's not actually true according to the documentation. (And if it
were, they could simply use -1 rather than a null pointer)

If you pass a null pointer in, the file's offset is used and *is*
updated, same as if you used an ordinary read/write call. If you pass a
value in, that value is used *and updated* (which makes it an output
parameter) and the file's offset is left alone.

Documentation below, I've >>>highlighted<<< the part that shows they are
used as output parameters:

       The following semantics apply for off_in, and similar statements
       apply to off_out:

       *  If off_in is NULL, then bytes are read from fd_in starting
       from
          the file offset, and the file offset is adjusted by the number
          of
          bytes copied.

       *  If off_in is not NULL, then off_in must point to a buffer that
          specifies the starting offset where bytes from fd_in will be
          read.
          The file offset of fd_in is not changed, >>>but off_in is
          adjusted
          appropriately.<<<


More information about the Python-Dev mailing list