diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-02-13 17:58:04 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-02-13 17:58:04 +0000 |
commit | 57bd60b465bddf801d0deb094f5ea671ab89068a (patch) | |
tree | 3b4216a873bddb5a8852cecb177f831a0a49d2d7 /Lib/test/test_abc.py | |
parent | 0a40ffb1b30a904eef00bb0c7ce4e18e7ca3dc75 (diff) | |
download | cpython-git-57bd60b465bddf801d0deb094f5ea671ab89068a.tar.gz |
Working on issue #1762: Brought
./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'isinstance(3, Fraction); isinstance(f, Fraction)'
from 12.3 usec/loop to 3.44 usec/loop and
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'
from 48.8 usec to 23.6 usec by avoiding genexps and sets in __instancecheck__
and inlining the common case from __subclasscheck__.
Diffstat (limited to 'Lib/test/test_abc.py')
-rw-r--r-- | Lib/test/test_abc.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py index 272f61df12..ac5f7ee245 100644 --- a/Lib/test/test_abc.py +++ b/Lib/test/test_abc.py @@ -83,6 +83,16 @@ class TestABC(unittest.TestCase): self.assertEqual(issubclass(C, A), True) self.assertEqual(isinstance(c, A), True) + def test_isinstance_invalidation(self): + class A: + __metaclass__ = abc.ABCMeta + class B(object): + pass + b = B() + self.assertEqual(isinstance(b, A), False) + A.register(B) + self.assertEqual(isinstance(b, A), True) + def test_registration_builtins(self): class A: __metaclass__ = abc.ABCMeta |