On Mon, 18 Aug 2014 00:43:58 -0400, Terry Reedy wrote:

>  >>> timeit.repeat('1+1')
> [0.04067762117549266, 0.019206152658126363, 0.018796680446902643]

I think you have been tripped up by the keyhole optimizer. I'm not 
entirely certain, but that's probably just measuring the overhead of 
evaluating the constant 2. Same applies to your other "constant + 
constant" tests.

This is in Python 3.3, and is suggestive:

py> bc = compile('1+1', '', 'exec')
py> from dis import dis
py> dis(bc)
  1           0 LOAD_CONST               2 (2) 
              3 POP_TOP              
              4 LOAD_CONST               1 (None) 
              7 RETURN_VALUE         



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to