This PR aims to add CasADi, a C++ library with SWIG-generated bindings to Python. CasADi is a
framework for Python and MATLAB (and Octave) which provides tools for nonlinear optimization and
algorithmic differentiation, and offers interfaces to several solver suites, which are not required
but can be turned on via CMake flags. Just the SUNDIALS solver suite is required to build, and the
rest of the interfaces are optional (they are not enabled because of the high build times).
This switches it so that when we call `jsobj.f()` instead of introspecting what
operations are possible on `jsobj.f` and creating an appropriate
callable `JsProxy` corresponding to the bound method, then calling this bound
method, then destroying the `JsProxy`, `_PyObject_GetMethod(jsobj, f_unicode)`
will now return a funny temporary object. We always use the same object so that
we don't need to allocate or destroy anything, and we know it must be
immediately called so we only check if the object is indeed callable.
This makes a HUGE difference to the efficiency of calling a method on a JsProxy,
reducing the time it takes by about 80%.
We assume that the return value of `_PyObject_GetMethod` is only expected to be
callable. In practice, it is only ever used once and then destroyed so we use
this to allow us to repeatedly reuse the same helper object.
This initial `PyObject_GenericGetAttr` is expected to fail, but it formats an
expensive AttributeError whenever it does. The internal method
`_PyObject_GenericGetAttrWithDict` has a `suppress` argument that makes it not
do this.
This saves between 40% and 70% of the time spent in JsProxy_GetAttr depending
on the return value.
Include type defintion files in pyodide-core.tar.gz
Remove snapshot related files.
Remove test files.
TODO in the future: Remove source maps and webworker.js?
As suggested in #4942
Rather than hand writing a thread state swap, this uses APIs for it. This should
reduce the amount of maintenance required to update Python.
Thanks markshannon for the suggestion.
I made https://github.com/hoodmane/f2c/ which has some improvements that make it
work much better for us including:
1. support for the `recursive` keyword
2. support for variable length arrays that are not arguments in recursive functions
3. `/COMMON/` blocks are labeled with `__attribute__((weak))`
4. automatically omits `ftn_len` arguments from calls to clapack
This allows us to delete most of `_f2c_fixes.py`.
Thanks to @ilayn for writing https://github.com/scipy/scipy/pull/20558,
`id_dist` was going to be a huge pain to deal with.
The scipy tests need hypothesis and without it the tests were exiting with exit
code 4 (Pytest usage error) but we were not checking the exit code so basically
not much was actually tested.