Search code examples
pythonoptimizationscipybytecodecpython

Python - from byte code to Python source code


I am going through scipy source code and: some optimization routine calls a function slsqp,

    # Call SLSQP
    slsqp(m, meq, x, xl, xu, fx, c, g, a, acc, majiter, mode, w, jw)

However, I cannot find the code for the body of this function. The file containing main wrapping routine with this function call is names slsqp.py. First statement in this module is

    from _slsqp import slsqp

so most probably details for this function are in _slsqp. However, in file (scipy 2.6, optimize lib), only _slsqp.pyc is available, not source code.

Is there a way to dissassemble? I have dis.dis in import dis, however this does not bring any source code. Or is source code available somewhere in scipy?

Kind regards.


Solution

  • _slsqp will be imported from a .so or .pyd file, depending on your OS. This means that the module is coded in C. scipy is open source. Of course the source code is available somewhere.