{"id":6904,"library":"symengine","title":"SymEngine Python Bindings","description":"SymEngine.py is a Python library providing high-performance wrappers to the SymEngine C++ symbolic manipulation library. It aims to offer a fast and efficient alternative for symbolic mathematics in Python, often used as a backend for SymPy or independently. The library is actively maintained, with frequent releases that typically follow updates to the core C++ SymEngine library.","status":"active","version":"0.14.1","language":"en","source_language":"en","source_url":"https://github.com/symengine/symengine.py","tags":["symbolic mathematics","CAS","computer algebra","high performance","C++ bindings","numerical computation"],"install":[{"cmd":"pip install symengine","lang":"bash","label":"PyPI"},{"cmd":"conda install python-symengine -c conda-forge","lang":"bash","label":"Conda"}],"dependencies":[{"reason":"Core symbolic manipulation engine, wrapped by this Python library.","package":"symengine (C++ library)"},{"reason":"Used for generating Python bindings from C++ code.","package":"cython","optional":true},{"reason":"Optional dependency for interoperability and extended functionality.","package":"sympy","optional":true},{"reason":"Optional dependency, especially for numerical evaluation (lambdify).","package":"numpy","optional":true}],"imports":[{"symbol":"symengine","correct":"import symengine"},{"symbol":"Symbol","correct":"from symengine import Symbol"},{"symbol":"sin","correct":"from symengine import sin"}],"quickstart":{"code":"import symengine\nfrom symengine import Symbol, sin\n\nx = Symbol('x')\ny = Symbol('y')\nexpr = x + y**2\nprint(f\"Original expression: {expr}\")\n\nderivative = expr.diff(y)\nprint(f\"Derivative with respect to y: {derivative}\")\n\n# Substitution\nsubstituted_expr = expr.subs(x, sin(y))\nprint(f\"Expression after substituting x=sin(y): {substituted_expr}\")","lang":"python","description":"This quickstart demonstrates how to define symbolic variables, create an expression, compute a derivative, and perform substitutions using SymEngine."},"warnings":[{"fix":"Ensure your Python environment meets the `requires_python` specification for the installed SymEngine version. Upgrade or downgrade Python as necessary.","message":"Python version support changes across major versions. For instance, v0.9.0 dropped Python 3.6 support, v0.11.0 required Python >=3.8, and v0.14.1 dropped Python 3.8 support. Always check `requires_python`.","severity":"breaking","affected_versions":"0.9.0, 0.11.0, 0.14.1"},{"fix":"If specific `lambdify` behavior is required, explicitly specify the `backend` argument. Ensure LLVM is correctly configured if you intend to use the LLVM backend for performance.","message":"The default backend for `lambdify` changed to LLVM when available in v0.10.0. This might alter performance or require LLVM dependencies if relying on `lambdify`'s default behavior.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Adjust code that expects mutable matrices after conversion or matrix operations. If mutability is critical, explicitly convert to a mutable matrix type after the operation.","message":"Conversion of `ImmutableMatrix` to SymPy/Sage results in immutable matrices since v0.10.0. Also, `Mul` and `Add` operations of immutable and dense matrices result in immutable matrices since v0.9.0.","severity":"breaking","affected_versions":">=0.9.0, >=0.10.0"},{"fix":"For ease of installation, use pre-built wheels via `pip install symengine` or the `conda` package. If building from source, ensure `cmake` is installed and the C++ SymEngine library is at a compatible version as specified in the `symengine.py` repository.","message":"Building `symengine` from source (e.g., via `pip install .` for development) requires `cmake` and often depends on a specific commit/tag of the core C++ SymEngine library. Mismatched versions can lead to build failures.","severity":"gotcha","affected_versions":"All versions (when building from source)"},{"fix":"Minimize explicit conversions between SymEngine and SymPy objects. If performance is critical, try to keep calculations within the SymEngine domain as much as possible. Consider using `symengine` as a backend for `sympy` where supported.","message":"Interoperability with `SymPy` can introduce performance overhead if SymEngine objects are frequently converted to SymPy objects and vice versa, as this might involve traversing expression trees and creating new objects.","severity":"gotcha","affected_versions":"All versions (when mixing SymEngine and SymPy)"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}