Python and the need for speed

Marko Rauhamaa marko at pacujo.net
Thu Apr 13 04:57:33 EDT 2017


Paul Rubin <no.email at nospam.invalid>:

> Marko Rauhamaa <marko at pacujo.net> writes:
>> As swapping is no longer considered normal on modern computers, the
>> memory-disk duality doesn't seem all that practical anymore. Rather,
>> you'd like to treat the disk analogously to network access and keep
>> RAM access separate.
>
> Yep. But opening disk files that way seems to require threads or extra
> processes.

At the moment, yes. But in the ideal world, everything would be
(optionally) nonblocking. So open(O_NONBLOCK) would return a file
descriptor before the system knows if the requested pathname refers to a
valid file.

Or maybe we should introduce a new "socket" family: AF_FILE. You would
do:

    f = socket.socket(socket.AF_FILE, socket.SOCK_STREAM, "rwb")
    f.setblocking(False)
    try:
        f.connect(pathname)
    except socket.error as e:
        if e.errno != errno.EINPROGRESS:
            raise
        ...
    ...


Marko



More information about the Python-list mailing list