Steven D'Aprano wrote:
> On 29/04/13 10:29, Ethan Furman wrote:
>>> - bool(1) # True
>> - int('11') # 11
>> - str(var) # whatever var had in it, now as a str
>> I think that's a red herring, because you're comparing the use of the
> object constructor with look-up by name.
How does what bool() is doing differ from a lookup?
It's not constructing a new instance. Neither is
int() in the cases where the argument is in the
range of values that it caches.
More generally, the built-in types can be thought
of as coercion functions -- they take an argument
and return some related value from the type's
repertoire. Whether they do that by constructing
a new object or not is an implementation detail.
--
Greg