[Python-Dev] Should we do away with unbound methods in Py3k?

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Nov 24 23:55:38 CET 2007


André Malo wrote:
> * Greg Ewing wrote:
 >
> > But you could just as well wrap
> > it in a function that takes self and discards it, 
> 
> I always thought, that this is exactly what staticmethod does.

Not quite -- staticmethod prevents a self from getting
passed in the first place, so there's no need to discard
it. Which is probably slightly more efficient, but if
unbound methods had never been invented in the first
place, I doubt that staticmethod would have been created
just for that reason.

The other thing about staticmethod is that it makes it
possible to call the method via either a class or an
instance, but I've never found a real need for that in
anything I've written or seen.

--
Greg


More information about the Python-Dev mailing list