On Sat, Oct 3, 2009 at 5:46 AM, Dag Sverre Seljebotn <[email protected]> wrote: > In the interest of fixing > > http://trac.cython.org/cython_trac/ticket/281 >
I was thinking on this a couple of days ago. Why the filename is not just passed to Pyx_AddTracebak... and further, why the lineno is not just stored the C function stack? > > I'm doing some benchmarks which are rather surprising to me. > You should not be surprised, your results are a total nonsense :-) > Explanations? One thing that is suspicious is this line PyThread_set_key_value(key, <void*>i) I think it should read: PyThread_set_key_value(key, <void*>&i) go to the actual implementation of that call, you will see assert(value != NULL); > Unless something is wrong it seems I can safely replace > __pyx_lineno and friends with thread variables (on Python versions which > support it, haven't checked that yet). > > In [12]: %timeit dagss.globalvar(1e3) > 100 loops, best of 3: 6.18 ms per loop > > In [13]: %timeit dagss.threadvar(1e3) > 10000 loops, best of 3: 553 micros per loop > > In [14]: %timeit dagss.threadvar(1e6) > 10 loops, best of 3: 153 ms per loop > > cdef extern from "pythread.h": > int PyThread_create_key() > void PyThread_delete_key(int) > int PyThread_set_key_value(int, void *) > void* PyThread_get_key_value(int) > void PyThread_delete_key_value(int key) > > cdef int v > > cdef void setvar(int x): > global v > v = x > > cdef int getvar(): > return v > > def threadvar(N): > cdef int key = PyThread_create_key() > cdef int i > cdef void* j > for i in range(N): > PyThread_set_key_value(key, <void*>i) > j = PyThread_get_key_value(key) > > def globalvar(N): > cdef int i > cdef int j > for i in range(N): > setvar(i) > j = getvar() > > > > > -- > Dag Sverre > _______________________________________________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev > -- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
