Message177967
Just for the record, I've compiled Raymond's roadmap version in Cython (with only slight changes to make 'self.maxsize' a Py_ssize_t and using an external .pxd for typing) and ran Serhiy's benchmark over it (Ubuntu 12.10, 64bit). This is what I get in Py3.4:
0.022 untyped_cy(i)
0.023 untyped_cy("spam", i)
0.024 untyped_cy("spam", "spam", i)
0.106 untyped_cy(a=i)
0.133 untyped_cy(a="spam", b=i)
0.152 untyped_cy(a="spam", b="spam", c=i)
0.033 typed_cy(i)
0.038 typed_cy("spam", i)
0.039 typed_cy("spam", "spam", i)
0.129 typed_cy(a=i)
0.168 typed_cy(a="spam", b=i)
0.183 typed_cy(a="spam", b="spam", c=i)
0.143 untyped_py(i)
0.234 untyped_py("spam", i)
0.247 untyped_py("spam", "spam", i)
0.368 untyped_py(a=i)
0.406 untyped_py(a="spam", b=i)
0.425 untyped_py(a="spam", b="spam", c=i)
0.447 typed_py(i)
0.469 typed_py("spam", i)
0.480 typed_py("spam", "spam", i)
0.745 typed_py(a=i)
0.783 typed_py(a="spam", b=i)
0.819 typed_py(a="spam", b="spam", c=i)
Looking at the factors, that's about the same speedup that the dedicated hand tuned C implementation presented according to Serhiy's own runs (he reported 10-25x). Makes me wonder why we should have two entirely separate implementations for this.
Here's the lru_cache_class.pxd file I used:
"""
cimport cython
cdef make_key(tuple args, dict kwds, bint typed, tuple kwd_mark)
@cython.final
@cython.internal
cdef class c_lru_cache:
cdef dict cache
cdef Py_ssize_t hits
cdef Py_ssize_t misses
cdef Py_ssize_t maxsize
cdef bint typed
cdef object user_function
cdef object cache_info_type
cdef tuple kwd_mark
cdef list root
""" |
|
Date |
User |
Action |
Args |
2012-12-23 10:08:24 | scoder | set | recipients:
+ scoder, rhettinger, amaury.forgeotdarc, pitrou, giampaolo.rodola, ezio.melotti, asvetlov, meador.inge, anacrolix, eric.snow, serhiy.storchaka, kachayev |
2012-12-23 10:08:24 | scoder | set | messageid: <1356257304.05.0.191753633479.issue14373@psf.upfronthosting.co.za> |
2012-12-23 10:08:24 | scoder | link | issue14373 messages |
2012-12-23 10:08:23 | scoder | create | |
|