Hi, all. I'm Jacob, a computational chemistry grad student new to Cython and still relatively inexperienced with programming in general. To make a long story short, the simulations my lab develops are leaking memory, so I want to use malloc() and free() to ensure that arrays that might be missed by the garbage collector can be fully deleted (our code involves matrix multiplications of numpy arrays on the order of 10 MB to simulate each time step of the simulation, so this piles up quickly).
Unfortunately, when I try to import these functions, the line
"from cython.cimports.libc.stdlib import malloc, free"
is throwing the error
"ModuleNotFoundError: No module named 'cython.cimports.libc.stdlib'"
I'm guessing that my usual python workflow is somehow wrong for Cython, but I don't know where to begin to figure out how, and I was hoping I could ask more experienced programmers for help. For reference, I am using PyCharm with a Conda environment. I have cython 3.0.0a9 installed. In the file where I am trying to import malloc and free, I do "import cython" before anything else and this causes no issues. I copied the import code directly from the
cython.readthedocs.io page on memory allocation, so I'm pretty sure it's not a syntax error. I've tried running my code in the console and in the terminal, both throw the same error.
Does anyone know how to get cython.cimports to play nice with Pycharm? I apologize if my question is ignorant, or if I've been making some obvious mistake. Thank you very much for taking the time to read this!
Yours in science,
Jacob Lynd