STINNER Victor added the comment:

For more fun, comparison between Python 2.7 / 3.4 / 3.6 / 3.6 FASTCALL.

----------------------------------+-------------+----------------+----------------+---------------
Tests                             |        py27 |           py34 |           
py36 |           fast
----------------------------------+-------------+----------------+----------------+---------------
filter                            |  165 us (*) |  318 us (+93%) |  237 us 
(+43%) |         165 us
map                               |  209 us (*) |  258 us (+24%) |         202 
us |  171 us (-18%)
sorted(list, key=lambda x: x)     |  272 us (*) |  348 us (+28%) |  237 us 
(-13%) |  163 us (-40%)
sorted(list)                      | 33.7 us (*) | 47.8 us (+42%) | 27.3 us 
(-19%) | 27.7 us (-18%)
b=MyBytes(); bytes(b)             | 3.31 us (*) |  835 ns (-75%) |  510 ns 
(-85%) |  561 ns (-83%)
namedtuple.attr                   | 4.63 us (*) |        4.51 us | 1.98 us 
(-57%) | 1.57 us (-66%)
object.__setattr__(obj, "x", 1)   |  463 ns (*) |         440 ns |  343 ns 
(-26%) |  222 ns (-52%)
object.__getattribute__(obj, "x") |  323 ns (*) |  396 ns (+23%) |         316 
ns |  196 ns (-39%)
getattr(1, "real")                |  218 ns (*) |   237 ns (+8%) |  264 ns 
(+21%) |  147 ns (-33%)
bounded_pymethod(1, 2)            |  213 ns (*) |  244 ns (+14%) |   194 ns 
(-9%) |  188 ns (-12%)
unbound_pymethod(obj, 1, 2)       |  345 ns (*) |  247 ns (-29%) |  196 ns 
(-43%) |  191 ns (-45%)
func()                            |  161 ns (*) |  211 ns (+31%) |         161 
ns |         157 ns
func(1, 2, 3)                     |  219 ns (*) |  247 ns (+13%) |  196 ns 
(-10%) |  190 ns (-13%)
----------------------------------+-------------+----------------+----------------+---------------
Total                             |  689 us (*) |  980 us (+42%) |         707 
us |  531 us (-23%)
----------------------------------+-------------+----------------+----------------+---------------


I didn't know that Python 3.4 was so much slower than Python 2.7 on function 
calls!?

Note: Python 2.7 and Python 3.4 are system binaries (Fedora 22), wheras Python 
3.6 and Python 3.6 FASTCALL are compiled manually.

Ignore "b=MyBytes(); bytes(b)", this benchmark is written for Python 3.

--

details:

Common platform:
Bits: int=32, long=64, long long=64, size_t=64, void*=64
Platform: Linux-4.4.4-301.fc23.x86_64-x86_64-with-fedora-23-Twenty_Three
CPU model: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz

Platform of campaign py27:
CFLAGS: -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
--param=ssp-buffer-size=4 -grecord-gcc-switches 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic 
-D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
--param=ssp-buffer-size=4 -grecord-gcc-switches 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic 
-D_GNU_SOURCE -fPIC -fwrapv
Python unicode implementation: UCS-4
Timer precision: 954 ns
Python version: 2.7.10 (default, Sep 8 2015, 17:20:17) [GCC 5.1.1 20150618 (Red 
Hat 5.1.1-4)]
Timer: time.time

Platform of campaign py34:
Timer info: namespace(adjustable=False, 
implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, 
resolution=1e-09)
CFLAGS: -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g 
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
-fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic 
-D_GNU_SOURCE -fPIC -fwrapv
Timer precision: 84 ns
Python unicode implementation: PEP 393
Python version: 3.4.3 (default, Jun 29 2015, 12:16:01) [GCC 5.1.1 20150618 (Red 
Hat 5.1.1-4)]
Timer: time.perf_counter

Platform of campaign py36:
Timer info: namespace(adjustable=False, 
implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, 
resolution=1e-09)
Python version: 3.6.0a0 (default:496e094f4734, Apr 22 2016, 02:18:13) [GCC 
5.3.1 20151207 (Red Hat 5.3.1-2)]
CFLAGS: -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes
Python unicode implementation: PEP 393
Timer: time.perf_counter

Platform of campaign fast:
Timer info: namespace(adjustable=False, 
implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, 
resolution=1e-09)
CFLAGS: -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes
Python unicode implementation: PEP 393
Python version: 3.6.0a0 (default:ad4a53ed1fbf, Apr 22 2016, 12:42:15) [GCC 
5.3.1 20151207 (Red Hat 5.3.1-2)]

----------
Added file: http://bugs.python.org/file42568/bench_fast-2.py

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

Reply via email to