[pypy-svn] pypy default: Turn functool.partial into a new-style class.

amauryfa commits-noreply at bitbucket.org
Wed Jan 26 00:21:19 CET 2011

Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Changeset: r41332:c837c7522105
Date: 2011-01-26 00:19 +0100

Log:	Turn functool.partial into a new-style class. This may help the JIT
	on socket objects.

diff --git a/lib_pypy/_functools.py b/lib_pypy/_functools.py
--- a/lib_pypy/_functools.py
+++ b/lib_pypy/_functools.py
@@ -3,12 +3,11 @@
 # reduce() has moved to _functools in Python 2.6+.
 reduce = reduce
-class partial:
+class partial(object):
     partial(func, *args, **keywords) - new function with partial application
     of the given arguments and keywords.
-    __slots__ = ['func', 'args', 'keywords']
     def __init__(self, func, *args, **keywords):
         if not callable(func):

diff --git a/lib-python/modified-2.7.0/test/test_functools.py b/lib-python/modified-2.7.0/test/test_functools.py
--- a/lib-python/modified-2.7.0/test/test_functools.py
+++ b/lib-python/modified-2.7.0/test/test_functools.py
@@ -45,6 +45,8 @@
         # attributes should not be writable
         if not isinstance(self.thetype, type):
+        if not test_support.check_impl_detail():
+            return
         self.assertRaises(TypeError, setattr, p, 'func', map)
         self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
         self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))

More information about the Pypy-commit mailing list