On 4/21/06, Giovanni Bajo <[EMAIL PROTECTED]> 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.
Remember that the current thought is "annotations" rather than "type specifiers", with any actual verication done by a separate decorator. If you really need to ensure list[int], then you can declare a subclass of list that verifies each element on instance creation or modification, and then use your decorator to replace any incoming sequence with a (possibly newly created) instance of this subclass. There will be some wasted work if another framework uses a different adapter class to say the same thing, but that should be the sort of "major boundary" where it is reasonable to verify things. If you pass an object out to code that doesn't care, they won't see any extra costs (unless they special case CheckExact). What they pass back may even still be the same object, and if not ... you can always remove the decorator for speed. -jJ _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com