From J.Demeyer at UGent.be Thu Jun 13 09:14:58 2019 From: J.Demeyer at UGent.be (Jeroen Demeyer) Date: Thu, 13 Jun 2019 15:14:58 +0200 Subject: [Cython] Reason for __Pyx_PyObject_Call2Args, __Pyx_PyObject_Call3Args Message-ID: <5D024C52.9090209@UGent.be> Is there any particular reason why Cython has specific code like __Pyx_PyObject_Call2Args, __Pyx_PyObject_Call3Args, ... And then there is even more complicated Python code in PyMethodCallNode generating something like __Pyx_PyObject_Call2Args for an arbitrary number of arguments. This could be simplified a lot by just writing code once to deal with n arguments and then letting the C compiler do the clever stuff: if you write a loop where the number of iterations is a small compile-time constant, the compiler should unroll it. I checked that GCC-6.4.0 is able to do this and the much simpler code with a for loop is as efficient as the current code. But maybe there are other compilers that don't do this (or there used to be such compilers when that code was written)? I stumbled on this while working on https://github.com/cython/cython/issues/2996 From stefan_ml at behnel.de Thu Jun 13 17:23:04 2019 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 13 Jun 2019 23:23:04 +0200 Subject: [Cython] Reason for __Pyx_PyObject_Call2Args, __Pyx_PyObject_Call3Args In-Reply-To: <5D024C52.9090209@UGent.be> References: <5D024C52.9090209@UGent.be> Message-ID: Jeroen Demeyer schrieb am 13.06.19 um 15:14: > Is there any particular reason why Cython has specific code like > __Pyx_PyObject_Call2Args, __Pyx_PyObject_Call3Args, ... > > And then there is even more complicated Python code in PyMethodCallNode > generating something like __Pyx_PyObject_Call2Args for an arbitrary number > of arguments. > > This could be simplified a lot by just writing code once to deal with n > arguments and then letting the C compiler do the clever stuff: if you write > a loop where the number of iterations is a small compile-time constant, the > compiler should unroll it. > > I checked that GCC-6.4.0 is able to do this and the much simpler code with > a for loop is as efficient as the current code. But maybe there are other > compilers that don't do this (or there used to be such compilers when that > code was written)? > > I stumbled on this while working on > https://github.com/cython/cython/issues/2996 It was originally written that way because there were slight differences, and only 0/1 args were special cased initially. The method optimisation then showed that it's worth special casing the self argument, which gave rise to the other helpers. I've seen your PR, which cleans this up very nicely. Thanks! Stefan From J.Demeyer at UGent.be Mon Jun 17 11:08:53 2019 From: J.Demeyer at UGent.be (Jeroen Demeyer) Date: Mon, 17 Jun 2019 17:08:53 +0200 Subject: [Cython] Working on METH_FASTCALL and vectorcall support Message-ID: <5D07AD05.9060105@UGent.be> Hello, this is just to let you know that I'm planning to add support for functions/methods defined with METH_FASTCALL instead of METH_VARARGS on CPython 3.7. Once this is implemented, it will be fairly easy to use vectorcall (PEP 590) for cython_function_or_method. Jeroen. From J.Demeyer at UGent.be Tue Jun 18 07:47:02 2019 From: J.Demeyer at UGent.be (Jeroen Demeyer) Date: Tue, 18 Jun 2019 13:47:02 +0200 Subject: [Cython] Empty defines of Py_TPFLAGS_METHOD_DESCRIPTOR? Message-ID: <5D08CF36.3030003@UGent.be> Hello, What's the purpose of commit https://github.com/cython/cython/commit/8ac1a6a55fc44ff858cc367af556250a91f71d16 I can't think of any reasonable scenario where Py_TPFLAGS_METHOD_DESCRIPTOR would be defined differently than in CPython (i.e. with value 1<<17). This is an honest question, I don't know what I'm missing. Jeroen. From stefan_ml at behnel.de Sun Jun 23 05:16:55 2019 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 23 Jun 2019 11:16:55 +0200 Subject: [Cython] Empty defines of Py_TPFLAGS_METHOD_DESCRIPTOR? In-Reply-To: <5D08CF36.3030003@UGent.be> References: <5D08CF36.3030003@UGent.be> Message-ID: <6aad2e64-c209-75f7-e9e8-5c1fd74780ff@behnel.de> Jeroen Demeyer schrieb am 18.06.19 um 13:47: > What's the purpose of commit > https://github.com/cython/cython/commit/8ac1a6a55fc44ff858cc367af556250a91f71d16 > > I can't think of any reasonable scenario where Py_TPFLAGS_METHOD_DESCRIPTOR > would be defined differently than in CPython (i.e. with value 1<<17). > > This is an honest question, I don't know what I'm missing. We define a couple of CPython flag names for older versions, and some of them are defined as 0 instead of their bit value, because we are not using them ourselves and it gives '&' tests an obvious 0 result. We don't define this one specifically, but I wanted to allow this kind of empty definition for the flag, that's all. Stefan From stefan_ml at behnel.de Sat Jun 29 06:21:38 2019 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 29 Jun 2019 12:21:38 +0200 Subject: [Cython] Backport language_level=2 fix? In-Reply-To: <5D149DFF.7050707@UGent.be> References: <5D149DFF.7050707@UGent.be> Message-ID: Jeroen Demeyer schrieb am 27.06.19 um 12:44: > Since Cython 3.0 doesn't seem close to being released, is there any chance > to backport https://github.com/cython/cython/pull/2792 > > It's a fairly simple and reasonable bugfix. Done: https://github.com/cython/cython/commit/d019d9f3e057cae5f873280bf78bce639f2a81da Stefan