Closed tyralla closed 3 months ago
While working on it, I found a bug that I fixed in b7b1d196b7cc51449947bd91d879036b64f8e94a.
Overwriting __dir__
(as discussed) above or initialising all arrays with None or a zero-length array (as discussed with @holgeralbert) could give us additional safety. However, we should only do this if we find that additional protection is required.
Executing the following statements within, e.g., Pycharm's Python Console results in a segfault:
The reason is that Pycharm tries to find information about Cython-level arrays that have not been initialised. Hence, our current workaround is to play around in Pycharm's Python Console only in the pure Python mode:
We could avoid this problem by activating Cython's
initializedcheck
option when compiling the models. However, this would increase simulation time by a few percent. Hence, we thought about just discussing this problem in the online documentation, but it would be clearly better if we could solve it without losing performance.Here is a toy example:
Making
p
private (_p
) or "special" (__p__
) does not help. But removingp
from thedir
results fixes the problem:I hope 99% of all potentially uninitialised arrays are hidden behind a
fastaccess
attribute. Hence, we could either removefastaccess
from the__dir__
methods of classes that define afastaccess
attribute (at best, only when working in Cython mode). Or, we could remove the potentially problematic arrays (or just everything) from the__dir__
method of allFastAccess
classes (at best, only from the Cython extension classes).