[Python-3000] Type Comparisons with Godel Numbers

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Apr 22 06:02:53 CEST 2006


Giovanni Bajo wrote:

> Another (similar) way would be to let the user pay for the high typechecking
> price in normal cases *but* provide a list[int] class, which is a list
> decorated with typechecks on modification operations. We could have
> list[int|float]() to construct a list which can hold either ints or floats.

This is worth thinking about. Recently when pondering the
question of when it would or would not be appropriate to
put in type assertions to help catch bugs, I concluded
that it makes the most sense to do so when building a
data structure, but not when just passing things around
between calls.

The most difficult-to-debug type errors are the ones
where you've put something of the wrong type into a
data structure, and it's sat there for a while not
causing any obvious problem until something else
tries to use it, by which time most evidence of where
it came from is gone.

So data structures which automatically check what you
put into them could be handy to have.

--
Greg


More information about the Python-3000 mailing list