Ruslan Dautkhanov <dautkha...@gmail.com> added the comment:

In [12]: cProfile.run("for _ in range(100_000): Bar()")                         
                                                                                
                                                   
         200003 function calls in 0.136 seconds                                 
                                                                                
                                                   
                                                                                
                                                                                
                                                   
   Ordered by: standard name                                                    
                                                                                
                                                   
                                                                                
                                                                                
                                                   
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)         
                                                                                
                                                   
        1    0.047    0.047    0.136    0.136 <string>:1(<module>)              
                                                                                
                                                   
   100000    0.079    0.000    0.089    0.000 typing.py:865(__new__)            
                                                                                
                                                   
   100000    0.010    0.000    0.010    0.000 {built-in method __new__ of type 
object at 0x55ab65861ac0}                                                       
                                                    
        1    0.000    0.000    0.136    0.136 {built-in method builtins.exec}   
                                                                                
                                                   
        1    0.000    0.000    0.000    0.000 {method 'disable' of 
'_lsprof.Profiler' objects}                                                     
                                                                
                                                                                
                                                                                
                                                   
                                                                                
                                                                                
                                                   
                                                                                
                                                                                
                                                   
In [13]: # And typing.py:865 points to                                          
                                                                                
                                                   
                                                                                
                                                                                
                                                   
In [14]: inspect.getsourcelines(Generic.__new__)                                
                                                                                
                                                   
Out[14]:                                                                        
                                                                                
                                                   
(['    def __new__(cls, *args, **kwds):\n',                                     
                                                                                
                                                   
  '        if cls in (Generic, Protocol):\n',                                   
                                                                                
                                                   
  '            raise TypeError(f"Type {cls.__name__} cannot be instantiated; 
"\n',                                                                           
                                                      
  '                            "it can be used only as a base class")\n',       
                                                                                
                                                   
  '        if super().__new__ is object.__new__ and cls.__init__ is not 
object.__init__:\n',                                                            
                                                           
  '            obj = super().__new__(cls)\n',                                   
                                                                                
                                                   
  '        else:\n',                                                            
                                                                                
                                                   
  '            obj = super().__new__(cls, *args, **kwds)\n',                    
                                                                                
                                                   
  '        return obj\n'],                                                      
                                                                                
                                                   
 865)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39168>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to