[PyPy-issue] [issue584] Consider wrapping functions that that are not functions in CPython

Armin Ronacher pypy-dev-issue at codespeak.net
Wed Dec 1 17:18:41 CET 2010


New submission from Armin Ronacher <armin.ronacher at active-4.com>:

A few things in Python are not functions and with that do not implement the
descriptor protocol. This has the handy side effect that they can be stored as
class attributes without becoming a method.

For instance I found that this code breaks in PyPy:

    import hashlib

    class MyClass(object):
        hash_method = hashlib.sha1

        def foo(self):
            h = self.hash_method()
            h.update(...)
            return h.hexdigest()

hashlib.sha1 is implemented as a function in PyPy and in this case automatically
becomes a function.  Instead it would probably be useful to have a wrapper that
removes the __get__ that makes a function a method.

----------
effort: medium
messages: 1910
nosy: mitsuhiko, pypy-issue
priority: wish
release: 1.4
status: unread
title: Consider wrapping functions that that are not functions in CPython

_______________________________________________________
PyPy development tracker <pypy-dev-issue at codespeak.net>
<https://codespeak.net/issue/pypy-dev/issue584>
_______________________________________________________



More information about the Pypy-issue mailing list