[Cython] Dash in the executable's filename

Robert Bradshaw robertwb at gmail.com
Mon Apr 27 18:15:03 CEST 2015


On Sun, Apr 26, 2015 at 11:16 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Robert Bradshaw schrieb am 24.04.2015 um 10:31:
>> On Thu, Apr 23, 2015 at 2:22 AM, Anton D. Kachalov wrote:
>>> I've found that executable script with dashes in the filename lead to
>>> produce wrong cythonized source:
>>>
>>>    $ touch my-great-script.py
>>>    $ cython my-great-script.py --embed
>>>    $ fgrep PyInit my-great-script.c
>>> PyMODINIT_FUNC PyInit_my-great-script(void); /*proto*/
>>> PyMODINIT_FUNC PyInit_my-great-script(void)
>>>   __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_my-great-script(void)",
>>> 0);
>>>           m = PyInit_my-great-script();
>>>
>>> So, if I don't want to import my final script elsewhere, I'm free to choose
>>> any filename for it.
>>
>> Good point: https://github.com/cython/cython/commit/e0fd2b3c8265ea40084ee9981d8601bc6e11b97e
>
> This change prevents finding the external .pxd file for the module. I
> noticed this by pure luck when several of the Cython optimised benchmarks
> in Demos/benchmarks/ suddenly dropped substantially in performance.
>
> https://sage.math.washington.edu:8091/hudson/view/bench/job/cython-devel-cybenchmarks-py3k/1400/artifact/bench_chart.html
>
> The build job compiles them as Python-embedded programs.

Arguably that's still correct behavior, similarly to how one can do
"import foo" when executing "python foo.py" and it's a new module.
However, I've undone this change for now (though "cython
my-great-script.py --embed" is now an error rather than produce bad C
code).


More information about the cython-devel mailing list