[pypy-issue] Issue #2634: datetime example where pypy3 is 30x slower (and pypy2 is 3x slower) (pypy/pypy)

Nathaniel Smith issues-reply at bitbucket.org
Wed Aug 16 01:04:09 EDT 2017


New issue 2634: datetime example where pypy3 is 30x slower (and pypy2 is 3x slower)
https://bitbucket.org/pypy/pypy/issues/2634/datetime-example-where-pypy3-is-30x-slower

Nathaniel Smith:

Test script adapted from gh16ito on IRC:
```python
# -*- encoding: utf-8 -*-
import time
from datetime import datetime, timedelta

def time_batch(batch_size, name, fn):
    start = time.time()
    for _ in range(batch_size):
        fn()
    end = time.time()
    print("{:.2f} µs/{}".format((end - start) / batch_size * 1e6, name))

def test_func():
    delta = timedelta(days=365+31+1, seconds=1+60+3600)
    dt = datetime(1900, 1, 1)

    for i in range(200):
        dt += delta

def test_func_ctime():
    delta = timedelta(days=365+31+1, seconds=1+60+3600)
    dt = datetime(1900, 1, 1)

    for i in range(200):
        dt += delta
        dt.ctime()

if __name__ == "__main__":
    while True:
        time_batch(10000, "test_func", test_func)
        time_batch(10000, "test_func_ctime", test_func)
```

CPython 2.7: ~22 µs/call

CPython 3.6: ~16 µs/call

PyPy2 5.8: ~60 µs/call

PyPy3 5.8: ~480 µs/call (after a long warm up period)




More information about the pypy-issue mailing list