Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61103 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r61098 | jeffrey.yasskin | 2008-02-28 05:45:36 +0100 (Thu, 28 Feb 2008) | 7 lines

  Move abc._Abstract into object by adding a new flag Py_TPFLAGS_IS_ABSTRACT,
  which forbids constructing types that have it set. The effect is to speed

    ./python.exe -m timeit -s 'import abc' -s 'class Foo(object): __metaclass__ = abc.ABCMeta' 'Foo()'

  up from 2.5us to 0.201us. This fixes issue 1762.
........
  r61099 | jeffrey.yasskin | 2008-02-28 06:53:18 +0100 (Thu, 28 Feb 2008) | 3 lines

  Speed test_socketserver up from 28.739s to 0.226s, simplify the logic, and make
  sure all tests run even if some fail.
........
  r61100 | jeffrey.yasskin | 2008-02-28 07:09:19 +0100 (Thu, 28 Feb 2008) | 21 lines

  Thread.start() used sleep(0.000001) to make sure it didn't return before the
  new thread had started. At least on my MacBook Pro, that wound up sleeping for
  a full 10ms (probably 1 jiffy). By using an Event instead, we can be absolutely
  certain that the thread has started, and return more quickly (217us).

  Before:
  $  ./python.exe -m timeit -s 'from threading import Thread'  't = Thread(); t.start(); t.join()'
  100 loops, best of 3: 10.3 msec per loop
  $  ./python.exe -m timeit -s 'from threading import Thread; t = Thread()'  't.isAlive()'
  1000000 loops, best of 3: 0.47 usec per loop

  After:
  $  ./python.exe -m timeit -s 'from threading import Thread'  't = Thread(); t.start(); t.join()'
  1000 loops, best of 3: 217 usec per loop
  $  ./python.exe -m timeit -s 'from threading import Thread; t = Thread()'  't.isAlive()'
  1000000 loops, best of 3: 0.86 usec per loop

  To be fair, the 10ms isn't CPU time, and other threads including the spawned
  one get to run during it. There are also some slightly more complicated ways to
  get back the .4us in isAlive() if we want.
........
  r61101 | raymond.hettinger | 2008-02-28 10:23:48 +0100 (Thu, 28 Feb 2008) | 1 line

  Add repeat keyword argument to itertools.product().
........
  r61102 | christian.heimes | 2008-02-28 12:18:49 +0100 (Thu, 28 Feb 2008) | 1 line

  The empty tuple is usually a singleton with a much higher refcnt than 1
........
diff --git a/Lib/abc.py b/Lib/abc.py
index d86b6ea..05ac7e4 100644
--- a/Lib/abc.py
+++ b/Lib/abc.py
@@ -52,50 +52,6 @@
     __isabstractmethod__ = True
 
 
-class _Abstract(object):
-
-    """Helper class inserted into the bases by ABCMeta (using _fix_bases()).
-
-    You should never need to explicitly subclass this class.
-    """
-
-    def __new__(cls, *args, **kwds):
-        am = cls.__dict__.get("__abstractmethods__")
-        if am:
-            raise TypeError("Can't instantiate abstract class %s "
-                            "with abstract methods %s" %
-                            (cls.__name__, ", ".join(sorted(am))))
-        if (args or kwds) and cls.__init__ is object.__init__:
-            raise TypeError("Can't pass arguments to __new__ "
-                            "without overriding __init__")
-        return super().__new__(cls)
-
-    @classmethod
-    def __subclasshook__(cls, subclass):
-        """Abstract classes can override this to customize issubclass().
-
-        This is invoked early on by __subclasscheck__() below.  It
-        should return True, False or NotImplemented.  If it returns
-        NotImplemented, the normal algorithm is used.  Otherwise, it
-        overrides the normal algorithm (and the outcome is cached).
-        """
-        return NotImplemented
-
-
-def _fix_bases(bases):
-    """Helper method that inserts _Abstract in the bases if needed."""
-    for base in bases:
-        if issubclass(base, _Abstract):
-            # _Abstract is already a base (maybe indirectly)
-            return bases
-    if object in bases:
-        # Replace object with _Abstract
-        return tuple([_Abstract if base is object else base
-                      for base in bases])
-    # Append _Abstract to the end
-    return bases + (_Abstract,)
-
-
 class ABCMeta(type):
 
     """Metaclass for defining Abstract Base Classes (ABCs).
@@ -118,7 +74,6 @@
     _abc_invalidation_counter = 0
 
     def __new__(mcls, name, bases, namespace):
-        bases = _fix_bases(bases)
         cls = super().__new__(mcls, name, bases, namespace)
         # Compute set of abstract method names
         abstracts = {name
@@ -129,7 +84,7 @@
                 value = getattr(cls, name, None)
                 if getattr(value, "__isabstractmethod__", False):
                     abstracts.add(name)
-        cls.__abstractmethods__ = abstracts
+        cls.__abstractmethods__ = frozenset(abstracts)
         # Set up inheritance registry
         cls._abc_registry = WeakSet()
         cls._abc_cache = WeakSet()