[Python-3000] Type Comparisons with Godel Numbers
Aahz
aahz at pythoncraft.com
Fri Apr 21 16:30:33 CEST 2006
On Sat, Apr 22, 2006, Greg Ewing wrote:
> Guido van Rossum wrote:
>>
>> If I have some utterly dynamic code that comes up with a list of a
>> million ints, and then I pass that as an argument to a function that
>> requests the argument type is list[int],
>
> you wrap it in something that checks elements for intness as you
> access them. It'll still check a million ints if you access them all,
> but that would have to be done anyway if you were passing the list
> to fully dynamic code. And it spreads the cost of doing it out over
> whatever is being done with the ints, rather than doing it all up
> front. And it doesn't bother checking any ints that you don't use.
Guido alluded to this, but let's make a specific example for clarity:
def foo(a -> list[int]):
for x in a:
blah blah
for y in a:
blah blah
How do we handle the cost of doing the typecheck in the second loop?
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Argue for your limitations, and sure enough they're yours." --Richard Bach
More information about the Python-3000
mailing list