[Python-ideas] IntFlags
Andrew Barnert
abarnert at yahoo.com
Fri Mar 6 17:09:07 CET 2015
On Mar 6, 2015, at 5:51, random832 at fastmail.us wrote:
> On Fri, Mar 6, 2015, at 04:28, Andrew Barnert wrote:
>> For example, if we were designing os.open or mmap or whatever as a
>> Pythonic interface, it wouldn't have a "flags" value that or's together
>> multiple integers. We'd probably have separate keyword-only arguments for
>> the less common flags, etc. But they weren't designed from scratch; they
>> were designed to closely mirror the POSIX APIs.
>
> It makes me wonder what the os module would look like if Windows (or
> VMS, OS/2, classic Mac, or whatever other OSes have been supported by
> python in the present or past) *didn't* provide close mirrors of the
> POSIX APIs as part of their C runtime library.
Classic Mac didn't provide anything remotely close to the POSIX APIs. IIRC, you called FSSpecMake to create an FSSpec structure from a volume ID, directory ID, and bare filename, then called FSSpecOpenDF with it, after which you'd call various other APIs to map blocks of data to memory handles.
For that matter, Win16 and early Win9x didn't have anything quite like the POSIX APIs, but mapping CreateFile and HANDLE values to open and file descriptors wouldn't be quite as ridiculous as mapping FSSpecOpenDF and refnum values.
At any rate, I think os.open has always been only available on Unix and NT. The whole point of it is to interface with libraries that want to use file descriptors or to access platform-specific features; if you want cross-platform files, you just call open. That's why the API is so close to the POSIX API; if it tried to wrap things up at a higher level, it wouldn't be able to provide access to flags that only Solaris offers, etc.
> I mean, it's not like we have opendir and readdir. And while we do have
> fork and exec, there's a reason beyond convenience for spawn. Because
> those are the functions that _don't_ exist, or don't work right, on
> non-Unix platforms.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas
mailing list