cython directives for %%cython magic

21 views
Skip to first unread message

Jonathan Kliem

unread,
Aug 11, 2020, 5:15:30 PM8/11/20
to sage-devel

If you load a cython file into a sage session the default cython directives are different from the directives on compile time. This might lead to different behaviour or errors, e.g. the following fails:

sage: %%cython
....: include "sage/data_structures/bitset.pxi"

If I understand correctly the cython directives while building sage are located in `src/sage_setup/command/sage_build_cython.py`:

153         self.cython_directives = dict(
154             auto_pickle=False,                                                        
155             autotestdict=False,
156             cdivision=True,                                                          
157             embedsignature=True,                                                      
158             fast_getattr=True,
159             language_level="3str",
160             preliminary_late_includes_cy28=True,                                      
161             profile=self.profile,                                                    
162         )      

The directive when loading into sage are located in `src/sage/misc/cython.py`.

317     directives = dict(language_level=sys.version_info[0])

The error is caused by `cdivision=True` missing. Is it acceptable to add it? Which others should be added?
Reply all
Reply to author
Forward
0 new messages