Skip to content

Interoperation with other libraries that use FLINT #420

Description

@magv

Hi, all. I'm writing a Python library that uses FLINT internally (i.e. there's some C code that uses FLINT and is then interfaced with via Cython), and I'd like to interoperate with python-flint by accepting and/or producing python-flint values (such as fmpq_mpoly). Could you advise on how to organize this best? Currently I'm just converting to Python and/or SymPy native types and back, and this is comically slow.

What I would like to have, ideally is:

  1. A way to take a python-flint value like fmpq_mpoly, and extract a pointer to the underlying fmpq_mpoly_struct, which I can pass to my C code directly.
    • Maybe this could be accomplished by shipping some Cython header files.
  2. A way to take an fmpq_mpoly_struct and produce a python-flint fmpq_mpoly object from it.
  3. A way to guarantee ABI compatibility with the FLINT version that python-flint builds against. Currently I'm building a static FLINT library that I link my Cython extensions with. I guess I would need to match the version of FLINT to the one you've used for this to be seamless?
    • A maximalist solution here would be a separate flint-dev-lib PyPI package that installs FLINT sources and prebuilt libraries to link against, so that both python-flint and other libraries that build against FLINT could be consistent. This package could be a part of python-flint as an alternative.
      Of course, this would require gmp-dev-lib and mpfr-dev-lib packages to exist, but we already build these libraries (same as you do), so it's not a major additional burden.

Anyway, I'd like to learn what you think of how to organize interoperability in Python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions