Andrew Straw | 19 Aug 16:26
Gravatar

[Cython] python version for conditional compilation?

Hi, looking at the Cython Sphinx documentation, I don't see the Python 
version as a variable I can use for conditional compilation. This would 
be handy in the case of newly added features in the Python-C API, for 
example. Would this be feasible to add (alongside UNAME_SYSNAME and 
friends)?

(The location of the docs I was looking at: 
http://www.mudskipper.ca/cython-doc/docs/language_basics.html#compile-time-definitions 
)
Gabriel Gellner | 19 Aug 16:37
Favicon

Re: [Cython] python version for conditional compilation?


>>----- Original Message -----
>>From: "Andrew Straw" <strawman@...>
>>To: cython-dev@...
>>Sent: Tuesday, August 19, 2008 7:26:39 AM GMT -08:00 US/Canada Pacific
>>Subject: [Cython] python version for conditional compilation?
>>
>>Hi, looking at the Cython Sphinx documentation, I don't see the Python 
>>version as a variable I can use for conditional compilation. This would 
>>be handy in the case of newly added features in the Python-C API, for 
>>example. Would this be feasible to add (alongside UNAME_SYSNAME and 
>>friends)?
>>
>>(The location of the docs I was looking at: 
>>http://www.mudskipper.ca/cython-doc/docs/language_basics.html#compile-time-definitions 
>>)

I maintain the Sphinx documentation, I don't fully know these features, but I will try to hunt down some
people at Scipy08 that do,
and I will write some of this in. Thanks for the heads up.

Gabriel
Fernando Perez | 20 Aug 08:03

Re: [Cython] python version for conditional compilation?

On Tue, Aug 19, 2008 at 7:37 AM, Gabriel Gellner <ggellner@...> wrote:

> I maintain the Sphinx documentation, I don't fully know these features, but I will try to hunt down some
people at Scipy08 that do,
> and I will write some of this in. Thanks for the heads up.

Tomorrow, Michael Droetboom will be in the intro tutorial lab teaching
( Moore Laboratory, Room 070 ).  He's very well versed in all things
Sphinx.  Since both Perry and I will do some of the teaching, Michael
should have some down time (esp. in the morning where you could ask
him).

Cheers,

f
Stefan Behnel | 19 Aug 16:53

Re: [Cython] python version for conditional compilation?

Andrew Straw wrote:
> Hi, looking at the Cython Sphinx documentation, I don't see the Python
> version as a variable I can use for conditional compilation. This would
> be handy in the case of newly added features in the Python-C API, for
> example. Would this be feasible to add (alongside UNAME_SYSNAME and
> friends)?

Feasible, yes, but it doesn't make much sense to check the Python version
at Cython compile time. The C code that gets generated by Cython will run
on all Python versions from 2.3 to 3.0, and on all major platforms. You
will loose that if you start generating platform-specific C code for the
system that happens to run Cython on your code.

Stefan

Robert Bradshaw | 19 Aug 19:17

Re: [Cython] python version for conditional compilation?

On Aug 19, 2008, at 7:53 AM, Stefan Behnel wrote:

> Andrew Straw wrote:
>> Hi, looking at the Cython Sphinx documentation, I don't see the  
>> Python
>> version as a variable I can use for conditional compilation. This  
>> would
>> be handy in the case of newly added features in the Python-C API, for
>> example. Would this be feasible to add (alongside UNAME_SYSNAME and
>> friends)?
>
> Feasible, yes, but it doesn't make much sense to check the Python  
> version
> at Cython compile time. The C code that gets generated by Cython  
> will run
> on all Python versions from 2.3 to 3.0, and on all major platforms.  
> You
> will loose that if you start generating platform-specific C code  
> for the
> system that happens to run Cython on your code.

If you want to do this I would recommend putting them in an actual .h  
file (with a cdef extern import block) so that the resulting .c files  
could be used on multiple Python versions.

Out of curiosity, what of the Python/C API do you need? (I'd rather  
to fix Cython to not have to directly call it.)

- Robert

(Continue reading)

Andrew Straw | 20 Aug 09:16
Gravatar

Re: [Cython] python version for conditional compilation?

Robert Bradshaw wrote:
> On Aug 19, 2008, at 7:53 AM, Stefan Behnel wrote:
>
>   
>> Andrew Straw wrote:
>>     
>>> Hi, looking at the Cython Sphinx documentation, I don't see the  
>>> Python
>>> version as a variable I can use for conditional compilation. This  
>>> would
>>> be handy in the case of newly added features in the Python-C API, for
>>> example. Would this be feasible to add (alongside UNAME_SYSNAME and
>>> friends)?
>>>       
>> Feasible, yes, but it doesn't make much sense to check the Python  
>> version
>> at Cython compile time. The C code that gets generated by Cython  
>> will run
>> on all Python versions from 2.3 to 3.0, and on all major platforms.  
>> You
>> will loose that if you start generating platform-specific C code  
>> for the
>> system that happens to run Cython on your code.
>>     
>
>   
Fair enough. But doesn't the UNAME_SYSNAME also make the C code 
platform-specific? (Not that one step down a slippery slope is an 
argument to take another. In fact, as noted below, my desire for this 
feature has dropped to near zero.)
(Continue reading)

Stefan Behnel | 21 Aug 07:20

Re: [Cython] python version for conditional compilation?

Hi,

Robert Bradshaw wrote:
> On Aug 19, 2008, at 7:53 AM, Stefan Behnel wrote:
> 
>> Andrew Straw wrote:
>>> Hi, looking at the Cython Sphinx documentation, I don't see the  
>>> Python
>>> version as a variable I can use for conditional compilation. This  
>>> would
>>> be handy in the case of newly added features in the Python-C API, for
>>> example. Would this be feasible to add (alongside UNAME_SYSNAME and
>>> friends)?
>> Feasible, yes, but it doesn't make much sense to check the Python  
>> version
>> at Cython compile time. The C code that gets generated by Cython  
>> will run
>> on all Python versions from 2.3 to 3.0, and on all major platforms.  
>> You
>> will loose that if you start generating platform-specific C code  
>> for the
>> system that happens to run Cython on your code.
> 
> If you want to do this I would recommend putting them in an actual .h  
> file (with a cdef extern import block) so that the resulting .c files  
> could be used on multiple Python versions.

No .h file required as the Python version is already in Python's patchlevel.h.
A simple

(Continue reading)


Gmane