[Python-Dev] file system path protocol PEP

Sven R. Kunze srkunze at mail.de
Fri May 13 12:33:47 EDT 2016


On 13.05.2016 17:29, Brett Cannon wrote:
> Purposeful change. It was what I had in my head after I posted my 
> "groups" breakdown email and what Guido suggested as well 
> independently. This helps alleviate any perf worries as type checks in 
> C are pointer checks that are cheap to make compared to attribute 
> lookup. And even if we do get the community to move on to path objects 
> the check is still cheap enough to not worry. And finally, this is 
> simply how we have almost always coded this kind of special-casing at 
> the C level throughout Python and the stdlib, so it now is more inline 
> with standard coding practices than the original proposal in the PEP.

Maybe, we have a misunderstanding here. Does "PyUnicode_Check(path)" 
respect subclass hierarchies such as isinstance(path, str) does? Could 
not find the definition of it in the source.

You said it's just a pointer comparison. To me that implies it could not 
respect subclasses as isinstance does. If that is the case, the C 
implementation differs from the Python version in semantics. I'm sorry 
if I misunderstood the whole implementation here.


Best,
Sven


More information about the Python-Dev mailing list