Hi, every experts: Recently I'm trying to move my old project from python to pypy. In the past, I have do some optimizations for python interpreter. One Important thing is modify python default integer object cache range(default is from -5 to 257), my config is -100 to 1024 * 1024, this range covers most of the my app logics. The benchmark shows that it saves a lot of memory , and speedup the program(mainly benefits from avoiding large amount of creating intobject and releasing intobject) .
BUT, in pypy, I found the withprebuiltint option is set off default. While I tried open this option and add translateoption : --prebuiltintfrom -5 --prebuiltintfrom 1048576, the benchmark shows that it saves memory(OK, it's expected), BUT the speed is SLOWER. I check the pypy sourcecode, but I have not find out the problem so far. So, my doubt is: why withprebuiltint option is off default? Maybe the performance is a problem as known? ############################################################################################# #test_speed4_prebuit_int.py def foo(): j = 0 for i in xrange(1024 * 1024): j = i -1 j = i + 1 import timeit print timeit.repeat(foo, repeat = 3, number= 100) user:~/pypy_run$ official-pypy/bin/pypy-c -B test_speed4_prebuit_int.py #default pypy [0.21457695960998535, 0.21348810195922852, 0.21274185180664062] user:~/pypy_run$ pypy-build-by-pypy-test/bin/pypy-c -B test_speed4_prebuit_int.py #--prebuiltintfrom -5 --prebuiltintfrom 1048576 [0.7308619022369385, 0.7308559417724609, 0.7256178855895996] #almost 3 times slower ############################################################################################# #test_mem4_prebuilt_int.py listlen = 1024 itemlen = 1024 * 100 x = 1 a = [None] * listlen def init_data(): for i in xrange(listlen): a[i] = [None] * itemlen def create_data(): for i in xrange(listlen): for j in xrange(itemlen - 1): a[i][j] = x + 0 init_data() create_data() ###mem test is expected, no problem Thanks regards! shadow 2016-12-14 _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev