[Python-Dev] SEEK_* constants in io and os (original) (raw)

Eli Bendersky eliben at gmail.com
Mon Sep 2 15🔞31 CEST 2013


On Mon, Sep 2, 2013 at 1:24 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:

Le Sun, 1 Sep 2013 18:02:30 -0700, Eli Bendersky <eliben at gmail.com> a écrit : > Hello, > > I was looking at the possibility of replacing the SEEK* constants by > IntEnums, and the first thing that catches attention is that these > constants are defined in both Lib/os.py and Lib/io.py; both places > also recently started supporting SEEKHOLE and SEEKDATA (though here > io refers to os.SEEKHOLE and os.SEEKDATA).

What is the runtime cost of doing so? os is a fundamental module that is imported by almost every Python program.

Theoretically, it should be very low given that we just need to add an import and define one class. os already does a number of things in its toplevel (mostly a few imports which transitively do other things). Compounded with import caching, since this is done just once per run, doesn't seem like a problem.

Empirically, I tried measuring it but I can't discern a difference with/without translating SEEK_* to enums. There's a fluctuation of ~1usec which I can't distinguish from noise. Let me know if you have a good methodology of benchmarking these things

Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130902/144c8345/attachment.html>



More information about the Python-Dev mailing list