On 15 August 2011 23:33, Dag Sverre Seljebotn <d.s.seljeb...@astro.uio.no> wrote: > Would it be horribly expensive to generate a better runtime error, or even > initialize the gil on demand? If the gil is not initialized, get the thread > ID of the thread calling the callback and check against the thread entering > at module initialization time...I don't know whether pythread.h has a cheap > way of achieving this.
I'm not sure how expensive PyThread_get_thread_ident(), for pthreads it calls pthread_self() is. So it's either such a call for every with gil, or initializing the GIL... I'll try to do some tests later today and report back. > -- > Sent from my Android phone with K-9 Mail. Please excuse my brevity. > > Stefan Behnel <stefan...@behnel.de> wrote: >> >> Dag Sverre Seljebotn, 15.08.2011 11:54: > On 08/15/2011 11:42 AM, mark >> florisson wrote: >> @Cython-dev: Do we merely want to update the docs, or do >> we want to >> initialize the GIL for either case, or only for the with gil >> >> functions? I'm not entirely sure what the overhead is for >> >> single-threaded code, but I'd say we need to initialize it for both >> >> cases. > > I'm not sure if I like magic related to having used "with gil" on >> a > function signature -- it's a bit too magic and obscure. I don't really >> like this either. The reason why the GIL is not being initialised by default >> is that it has a runtime impact. Just because code is aware of threading >> does not mean it is going to be used with threads. Especially library code >> (which is a common place for using Cython) shouldn't impose such an impact >> on the rest of the runtime. Stefan >> ________________________________ >> cython-devel mailing list cython-devel@python.org >> http://mail.python.org/mailman/listinfo/cython-devel > > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel > > _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel