Jupyter notebook needs to import all modules for each cell

2 views
Skip to first unread message

Wei-Ting Lin

unread,
Nov 20, 2025, 2:56:40 PM (2 days ago) Nov 20
to cython-users
I just start using Cython very recently. Thanks for this great package. 

The Jupyter magic "%%cython" is convenient, but it seems I need to import the modules used in the cell every time. 
For example, I need 
"
import cython as C
import numpy as np
for each cell using numpy. 

Is there a way to make cython automatically use the imported modules in the session? 

Thank you. 

Jérôme Kieffer

unread,
Nov 21, 2025, 1:49:24 AM (2 days ago) Nov 21
to cython...@googlegroups.com
Dear Wei-Ting Lin,

Each notebook cell is compiled as a (separate) python extention (binary
module, imported later on) so they behave like different python modules.

This is the normal behavour.

Cheers,

Jerome
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/cython-users/ed46ce88-8830-4cdf-9a7a-fa30be744d8cn%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages