Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Stefan Behnel <stefan_ml-KjMAwuNBv5izQB+pC5nmwQ <at> public.gmane.org>
Subject: Re: [Cython] [cython-users] Conditional import in pure Python mode
Newsgroups: gmane.comp.python.cython.devel
Date: Tuesday 1st May 2012 09:21:12 UTC (over 4 years ago)
>>> On 29 April 2012 01:33, Ian Bell wrote:
>>>> idiom like
>>>>
>>>> if cython.compiled:
>>>>     cython.import('from libc.math cimport sin')
>>>> else:
>>>>     from math import sin

Actually, in this particular case, I would even accept a solution that
special cases the "math" module internally by automatically cimporting
libc.math as an override (or rather an adapted version as plain
"math.pxd").

This CEP describes a general approach:

http://wiki.cython.org/enhancements/overlaypythonmodules

It's partly outdated, so things may have become easier these days.

Stefan
 
CD: 3ms