[Python-3000] callable()

Collin Winter collinw at gmail.com
Wed Jul 26 00:15:47 CEST 2006


On 7/25/06, Andrew Koenig <ark-mlist at att.net> wrote:
> > With your CD example, you need an external resource (the CD itself) in
> > order to calculate the hash - in that case, you can't safely defer
> > the hash calculation until the first time you know you need it,
> > since you don't know whether or not you'll have access to the
> > physical CD at that point.
>
> OK.  Then instead of a CD, use a (read-only) disk file.  The example is
> still valid in that case, and avoids the extraneous matter of operator
> intervention.

Oh, please. No-one's arguing that hashes MUST be fast to compute; it's
just a good rule of thumb. There will of course be exceptional cases,
like the contrived examples you've come up with, but they're just
that: exceptional. If you find yourself writing classes that must hash
a large on-disk file or CD or whatever else, you can add custom tests
for hashability yourself. There's no need to clutter the language to
cater to every odd corner case someone digs up.


Collin Winter

PS: A read-only disk file has the same problem that Nick pointed out
with your CD example, namely that that file might not exist when you
try to compute the hash. Just because it's read-only to you doesn't
mean the superuser can't remove it.


More information about the Python-3000 mailing list