• Python?s OS-specific API support

    From Lawrence D?Oliveiro@3:633/10 to All on Wed Mar 25 01:32:19 2026
    I?ve been looking at the docs for Python?s ?os? module <https://docs.python.org/3/library/os.html>. This contains a
    collection of low-level interfaces that are specific to particular
    operating system platforms. And it?s turning into quite a sprawling
    hodge-podge of function calls and symbol definitions for use with
    same: I think it?s already up to about 60 printed pages.

    Just for a fun, I did a count of the ?availability? info for various
    features, grouped by the platforms mentioned. My count could be a bit
    off by one or two, but judging from the numbers, this will not
    appreciably affect any ranking judgements you might want to draw.

    Far and away, the number-one platform supported was ?Unix?, with 141
    different mentions. This includes a section titled ?Interface to the scheduler?, which warns it is only applicable on ?some Unix
    platforms?, not necessarily all of them.

    In second place, almost neck-and-neck, are ?Linux? (33 mentions) and
    ?Windows? (32 mentions). I suppose if all the ?xattr? functions had
    their own separate ?availability? clauses (as is done in most places elsewhere), this would put Linux comfortably in the lead. And don?t
    forget that all the ?Unix? and ?POSIX? ones apply to Linux as well,
    with just one exception.

    It is interesting to note that none of the pseudo-terminal functions,
    and few of the ones for controlling terminals from the client side,
    are supported on Windows. All of these are available on ?Unix?.

    There are also a couple of mentions of availability under ?POSIX?,
    though I?m not sure why this is distinct from ?Unix?. There is also a
    single mention of a macOS-specific API -- special process-priority
    values only available on that platform. And two places where functions
    are specifically mentioned as being available on particular BSD
    variants.

    The solitary ?Unix? function not available on Linux is lchmod(), which
    is not in POSIX anyway. This is also unavailable on OpenBSD, though
    FreeBSD and NetBSD support it.

    Is this a sign of the relative popularity of those platforms for
    Python programming? I think it could be.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)