[Python-ideas] Dunder method to make object str-like

Random832 random832 at fastmail.com
Thu Apr 7 12:31:23 EDT 2016

On Thu, Apr 7, 2016, at 12:11, Paul Moore wrote:
> OK, that makes sense. But when you say "it'll work fine in Python 3"
> how will that happen? What code needs to call __fromstring__ to make
> this happen? You mention getattr. Would you expect every builtin and
> stdlib function that takes a string to be modified to try
> __fromstring__? That sounds like a pretty big performance hit, as
> strings are very critical to the interpreter.

Isn't it only a performance hit on something that's an exception now?
Like, if PyString_Check fails, then call it.

I wonder how much could be done in a "blanket" way without having to
change individual methods. Like, put the necessary machinery in
PyArg_ParseTuple. Or does that borrow a reference?


Taking a step back, can someone explain to me in plain english why io
and os shouldn't directly support pathlib? All this "well maybe make it
a subclass, well maybe make a special protocol stuff can implement"
stuff is dancing around that.

More information about the Python-ideas mailing list