symengine.py icon indicating copy to clipboard operation
symengine.py copied to clipboard

Subclassed Symbols that define `__getitem__` break `DenseMatrix`

Open bocklund opened this issue 7 months ago • 2 comments

Here's a self-contained test

from symengine import Symbol, DenseMatrix
class MySymbol(Symbol):
    def __getitem__(self, x):
        pass
x = Symbol("x")
y = MySymbol("y")
DenseMatrix([x])  # works fine
DenseMatrix([y])  # SIGSEGV

In PyCalphad (https://github.com/pycalphad/pycalphad/issues/547), we have something where __getitem__ returns, effectively, a new MySymbol, and think ends up in some loop where MySymbol keeps getting created and eats all the system memory.

bocklund avatar Jul 22 '24 17:07 bocklund