[issue15078] Change os.sendfile so its arguments are stable

Larry Hastings report at bugs.python.org
Sat Jun 16 02:28:06 CEST 2012


Larry Hastings <larry at hastings.org> added the comment:

> There are some other functions with strange/variable prototype:
> http://docs.python.org/dev/library/fcntl.html?highlight=ioctl#fcntl.ioctl
> http://docs.python.org/dev/library/mmap.html?highlight=mmap.mmap#mmap.mmap

It does not follow that this behavior is desirable, or that it should be emulated in new code.  There's a lot of legacy code with unexpected API design that would not pass muster were it proposed today.

Consider this: what should the Signature (PEP 362) for fcntl.ioctl look like?


> These Python functions are thin wrapper of the C function,
> that's why their prototype can be surprising.

The "thin wrapper" os.sendfile is 130 lines of C.   Furthermore I disagree with the idea that os does or should contain "thin wrappers".  It strikes me as unbearably provincial thinking among UNIX developers.  Anyone who thinks os contains "thin wrappers" should examine the Windows implementation of stat().

But at the heart of the matter, I see no benefit to exposing Python developers to the idiosyncrasies of poor C API design.  I feel strongly that one way Python becomes "pythonic" is that it aims for the convenience of the programmer--not the language designer and not the implementer.  The Python calling convention is far more flexible than the C calling convention.  We should put it to good use here.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15078>
_______________________________________


More information about the Python-bugs-list mailing list