[Python-ideas] PEP: Extended stat_result (First Draft)
Pieter Nagel
pieter at nagel.co.za
Mon May 6 22:02:12 CEST 2013
On Mon, 2013-05-06 at 21:46 +0200, Giampaolo Rodola' wrote:
> I don't understand what your proposal has to do with calling os.stat()
> once or twice (you can already call it once and use stat.S_IS*
> functions).
I am referring to the impedance mismatch between the way the code is
spelled in the two cases.
Given code like "os.path.isfile(f)", one has to make a rather convoluted
mental mapping to stat.S_ISREG if one wants to do essentially the same
thing, but this time on a stat result.
That convoluted mapping creates a mental impedance mismatch, and that
mismatch makes it more difficult / less likely that code would be
transformed into the more performant form.
Then one has to take into account that novices tend to be more familiar
with the easier, straightforward ways of doing things, so for them I
think that would be isfile() and the like. For them, bitmasks on a
subfield is even more of leap.
In fact, one could say that the stat module as it is today already
breaks TOOWTDI, (because it provides a totally different mechanism for
interrogating file types than os.path does).
My proposal is more in the spirit of fixing a violation of TOOWTDI than
of adding extra ways to do things just for the heck of it.
--
Pieter Nagel
More information about the Python-ideas
mailing list