[Python-Dev] stat module in C -- what to do with stat.py?
victor.stinner at gmail.com
Fri Jun 21 00:58:44 CEST 2013
2013/6/20 Serhiy Storchaka <storchaka at gmail.com>:
> Now with enumerations in the stdlib the stat module constants are candidates
> for flag enumerations. How easy will be implement it on C?
Numerical values are less important than S_ISxxx() macros. Example:
#define S_ISDOOR(mode) (((mode)&0xF000) == 0xd000)
0xd000 is (stat.S_IFSOCK + stat.S_IFIFO).
And how do you represent the file mode with enums? I don't think that
enum should be used in the stat module.
I would prefer a stat object with methods than having to calls
low-level functions. Something like:
The idea was discussed in http://bugs.python.org/issue11406 to solve a
real API design issue. How should os.scandir() return the "is a
directory" information with a portable API.
I'm not saying that stat.S_ISREG should go away. The two approaches
More information about the Python-Dev