hi all, I don't have a good feeling for this just looking at the code, so i ask in here

would i be totally crazy to try replacing uses of sympy.Symbol with symengine's symbol class in a biggish python codebase?

i don't have a strong feeling for how experiemental symengine is at the moment

it would be cool if I could structure things such that if symengine and the python wrappers are installed users get free speedup :)

@ngoldbaum, just replacing the symbol will not be enough. You will have to replace calls to sympy functions with calls to symengine functions. For example,

```
try:
from symengine import sin
except ImportError:
from sympy import sin
```

SymEngine only has a few functions compared to SymPy. What functionality from SymPy are you using?

Replacing SymPy's symbol with SymEngine's symbol should work without a problem. (If not it's a bug in SymPy).

Right now, SymEngine's symbols are converted back into SymPy's when SymPy's functions are called, therefore the speedup depends on how you use the symbols

Right now, SymEngine's symbols are converted back into SymPy's when SymPy's functions are called, therefore the speedup depends on how you use the symbols

@certik, here's the branch that I've been working on, https://github.com/isuruf/symengine/tree/pynumber

@ngoldbaum Isuru is right. Let us know what functionality you need and we can implement it. The code is in development, but it should be correct and work.

@isuruf I am still having problems understanding the two options for derivatives. The notebook looks great.

I haven't implemented derivative yet.

One option, when initializing the PyFunctionClass object (which has a pointer to a python function) we can call the derivative of it with general symbols. Like `besselk(x1, x2)`

and get the derivative with respect to the first symbol and second symbol stored in the PyFunctionClass object. Later, when we want to get the derivative of a particular instance, we calculate the derivative using the stored objects.

Second option, call derivative on the instance when needed

Ah. I would definitely only call the derivative if it is needed, otherwise if it is not needed, you waste time, don't you?

I'll implement the second one.

Agreed. Thanks for working on this. Please ping me anytime if you need any help.

@isuruf @certik thank you! I may try making a toy example at some point if/when I have a chunk of time :)

good luck with symengine - sympy is very powerful but i've found that sometimes the overhead of using it is quite high, which can make for some annoying reimplementation work that needs to happen whenever we find that something in sympy is more expensive than we originally thought

@ngoldbaum exactly, that's the idea behind SymEngine, to have the fastest implementation. Sometimes, it might be the symbolic algorithm itself that is slow, but at least with SymEngine it will run as fast or faster than other libraries.

If you find a case, when other programs like Mathematica are faster, please let us know.