From oliver.sebastian.haas at gmail.com Sun Aug 2 07:44:30 2020 From: oliver.sebastian.haas at gmail.com (Oliver Haas) Date: Sun, 2 Aug 2020 13:44:30 +0200 Subject: [Cython] Infer types and array.pxd Message-ID: Hello everyone, The array.pxd ( https://github.com/cython/cython/blob/master/Cython/Includes/cpython/array.pxd) requires infer_types = True when cimported. Is there a reason not to explicitly type the variable op as array in the lines 134 and 141? Regards Oliver -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Sun Aug 2 09:18:52 2020 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 2 Aug 2020 15:18:52 +0200 Subject: [Cython] Infer types and array.pxd In-Reply-To: References: Message-ID: Oliver Haas schrieb am 02.08.20 um 13:44: > The array.pxd ( > https://github.com/cython/cython/blob/master/Cython/Includes/cpython/array.pxd) > requires infer_types = True when cimported. Is there a reason not to > explicitly type the variable op as array in the lines 134 and 141? The return type of the function that creates the object is known, so the normal (safe) type inference should work here without setting "infer_types=True". Do you want to set "infer_types=False", or why is this failing for you? Stefan From dw-git at d-woods.co.uk Sun Aug 2 11:02:39 2020 From: dw-git at d-woods.co.uk (da-woods) Date: Sun, 2 Aug 2020 16:02:39 +0100 Subject: [Cython] Infer types and array.pxd In-Reply-To: References: Message-ID: I'm not convinced that compiler directives like "infer_types" should propagate into the cimported files at all. It seems reasonable to me that these should be controlled by the author of the pxd file, not by the eventual cimporter. On 02/08/2020 14:18, Stefan Behnel wrote: > Oliver Haas schrieb am 02.08.20 um 13:44: >> The array.pxd ( >> https://github.com/cython/cython/blob/master/Cython/Includes/cpython/array.pxd) >> requires infer_types = True when cimported. Is there a reason not to >> explicitly type the variable op as array in the lines 134 and 141? > The return type of the function that creates the object is known, so the > normal (safe) type inference should work here without setting > "infer_types=True". Do you want to set "infer_types=False", or why is this > failing for you? > > Stefan > _______________________________________________ > cython-devel mailing list > cython-devel at python.org > https://mail.python.org/mailman/listinfo/cython-devel From stefan_ml at behnel.de Sun Aug 2 13:23:41 2020 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 02 Aug 2020 19:23:41 +0200 Subject: [Cython] Infer types and array.pxd In-Reply-To: References: Message-ID: <18F87FB2-118F-4D3B-AE34-4BBE4E614630@behnel.de> Am 2. August 2020 17:02:39 MESZ schrieb da-woods: > I'm not convinced that compiler directives like "infer_types" should > propagate into the cimported files at all. > > It seems reasonable to me that these should be controlled by the author > of the pxd file, not by the eventual cimporter. I agree. It might not be as strikt as that, there could still be directives that should be inherited, but definitely not all of them. Can't look right now, but there might already be a ticket about this. Stefan From dw-git at d-woods.co.uk Sun Aug 2 13:43:27 2020 From: dw-git at d-woods.co.uk (da-woods) Date: Sun, 2 Aug 2020 18:43:27 +0100 Subject: [Cython] Infer types and array.pxd In-Reply-To: <18F87FB2-118F-4D3B-AE34-4BBE4E614630@behnel.de> References: <18F87FB2-118F-4D3B-AE34-4BBE4E614630@behnel.de> Message-ID: <275081ac-d45a-30e4-caec-44c605d33393@d-woods.co.uk> https://github.com/cython/cython/issues/1071 On 02/08/2020 18:23, Stefan Behnel wrote: > Am 2. August 2020 17:02:39 MESZ schrieb da-woods: >> I'm not convinced that compiler directives like "infer_types" should >> propagate into the cimported files at all. >> >> It seems reasonable to me that these should be controlled by the author >> of the pxd file, not by the eventual cimporter. > I agree. It might not be as strikt as that, there could still be directives that should be inherited, but definitely not all of them. > > Can't look right now, but there might already be a ticket about this. > > Stefan > _______________________________________________ > cython-devel mailing list > cython-devel at python.org > https://mail.python.org/mailman/listinfo/cython-devel From oliver.sebastian.haas at gmail.com Mon Aug 3 02:24:24 2020 From: oliver.sebastian.haas at gmail.com (Oliver Haas) Date: Mon, 3 Aug 2020 08:24:24 +0200 Subject: [Cython] Infer types and array.pxd In-Reply-To: References: Message-ID: Hello, - Yes, I prefer to work with infer_types = False most of the time. I can see how this might be rare, so in general this isn't an important issue. - I think the best solution would be that compiler directives like "infer_types" should not propagate into the cimported files at all, but rather be controlled by the actual author (roughly citing da-woods here). I don't think this will be easy to do in general, but especially with *.pxd files and inline functions. - As a reasonable solution I would just submit a pull request with added explicit typing if I encounter a case like this one in array.pxd. I don't see any downside in that, but I'm not experienced so I wanted to ask first. Regards. Oliver -------------- next part -------------- An HTML attachment was scrubbed... URL: