Message12026

Author jamesmudd
Recipients jamesmudd, jeff.allen, stefan.richthofer
Date 2018-06-27.19:47:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530128863.7.0.56676864532.issue2672@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks Stefan I have redone it without the print with very different results which I don't understand. Here they are:

CPython 2
	Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
	[GCC 5.4.0 20160609] on linux2
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import timeit
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	0.13201189041137695
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	0.0979149341583252
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	0.09714412689208984

CPython 3
	Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
	[GCC 5.4.0 20160609] on linux
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import timeit
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	0.08939030999954412
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	0.09239740000066377
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	0.12687400600043475


Jython current master
	Jython 2.7.2a1+ (, Jun 27 2018, 19:16:18) 
	[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_171
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import timeit
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	2.0910000801086426
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	2.120000123977661
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	2.115000009536743

Jython with BigInteger promotion fix
	Jython 2.7.2a1+ (, Jun 27 2018, 20:36:23) 
	[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_171
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import timeit
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	2.7939999103546143
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	2.6410000324249268
	>>> timeit.timeit('"%d" % 64726787', number=10000000)
	2.635999917984009

Some things to note. This is now without the print so that should be fixed, however its also with much fewer repeats "only" 10,000,000 (10 million) not 1 billion as before. The reason is Jython was hanging with 1 billion, maybe I just didn't wait long enough. So now CPython is much faster than Jython, and Jython is slower to do this 10m times than it was to do the print + this 1b times, so I really don't understand what this is doing! With this result the BigInteger performance is significantly worse (~25% slower) than without so I think that's a reason to go with the constant. Not much difference between python 2 and 3.

Just if someone can explain this I would like to know!
History
Date User Action Args
2018-06-27 19:47:43jamesmuddsetmessageid: <1530128863.7.0.56676864532.issue2672@psf.upfronthosting.co.za>
2018-06-27 19:47:43jamesmuddsetrecipients: + jamesmudd, jeff.allen, stefan.richthofer
2018-06-27 19:47:43jamesmuddlinkissue2672 messages
2018-06-27 19:47:43jamesmuddcreate