tBuLi / kingdon

A symbolically optimized and pythonic Clifford (geometric) algebra library named after none other than William Kingdon Clifford.
https://tbuli.github.io/teahouse/
MIT License
45 stars 5 forks source link

OperatorDict performance #11

Closed tBuLi closed 6 months ago

tBuLi commented 2 years ago

The current OperatorDict implementation accepts an erbitrary number of multivectors. However, this introduces a lot of overhead while the typical usecases are unary and binary operators. Therefore, we should have dedicated functionality for these scenarios in order to significantly improve the performance of the __call__ method of this object. I would prever to implement a __call_unary__ and __call_binary__ method for these scenarios instead of subclassing, such that we can still use the general cases if needed.

pckroon commented 2 years ago

What you could do is give an OperatorDict a write-once attribute indicating if which usecase it should cover. __call__ can then dispatch to more specific methods based on that attribute. I think that would be the cleanest. Alternatively you code do some live code generation with MixIns, but there be dragons

tBuLi commented 6 months ago

Already addressed.