[Python-3000] Generic function PEP won't make it in time

Jim Jewett jimjjewett at gmail.com
Wed Apr 25 22:03:32 CEST 2007

On 4/25/07, Josiah Carlson <jcarlson at uci.edu> wrote:

> Please remember that this isn't about Java style type checking and
> verification during compilation.  This is, strictly speaking, ABC
> checking on object instantiation, method invocation, and possibly even
> argument verification.  This isn't the magic bullet you are looking for
> (you'll have to go to one of those static typed languages for that).

Yes and no.

With duck typing, you call the method when you're ready to use it.  At
best, he could pre-check his objects to ensure that they have the
methods he'll need later.  There will inevitably be times when the
"wrong" object slips by.

With an ABC, he gets a quick check that the object at least *claims*
to do the right thing (as opposed to having unrelated methods of the
same name), and that they have taken *some* effort to fulfill this
pledge.  The upside is that there won't be as many wrong objects
getting by.  The downside is that there will be some objects which get
wrongly rejected.  (gmpy.mpz is probably a good enough integer, even
before it gets updated to say so.)

For Ermin's use case, a few false rejections is cheaper than a few false hits.


More information about the Python-3000 mailing list