-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should python-flint abstract over Flint's C types #55
Comments
Thinking about this a bit I think that maybe the ideal would be to have three levels of API:
Then level 0 is good for prototyping etc. Level 1 is good for having a nicer interface when you want precise control of lower-level routines and is probably best for libraries that might use pthon-flint. Level 2 ends up being the interface for python-flint's direct end users. |
I think a level 0 that works for flint like https://github.com/cython/cython/tree/master/Cython/Includes/cpython works for the cpython internals is both workable and a good idea. This would entail taking what is now _flint.pxd and blowing it up into a submodule of python flint. As @fredrik-johansson notes this can (mostly) be done by parsing the .rst files. I think the only question is whether we want this to be a submodule of python-flint or a separate module altogether (I don't see much point to a separate module, but I know little about library distribution) On a related note do we want to export the cython interface to python interface as well? Right now there isn't much point as most of the methods are just If I understand the level 2 interface would be much like a python layer over flint's new generics. |
It can just be a submodule like
I assume that what you mean here is should python-flint expose cython functions/methods that can be used for downstream cython code? Then if a downstream library is written in cython it can call some of python-flint's cython functions/methods. This is something that I know very little about: I don't know how exactly exposing a cython interface from one package to another works in practice. I am not sure exactly how to expose a Cython interface or what the benefits or limitations would be.
Possibly, although I am still a bit unclear about exactly where Flint's new generics are going to end up. Level 2 could just be a nicer level over the top of level 1 that abstracts away the things that can be abstracted (like the distinction between Basically in my mind level 2 looks more like a simple CAS and is designed to have a nice CAS interface for users. For now my intention in distinguishing level 2 is really to say that we should not worry too much about trying to design a "nice" interface at level 1 and should just focus on making it as complete as possible in wrapping flint's most important functionality in a way that is fast and safe (no segfaults etc, unlike level 0). It is easy to get tied down in designing the ideal UI once you start thinking of a CAS but if we just remember that there can be a separate level 2 for that then we can avoid worrying too much about it for level 1. |
The basic question here is whether it makes sense to distinguish between things like
nmod
vsfmpz_mod
in python-flint. Currently python-flint only hasnmod
. It would be good to addfmpz_mod
but should it even be exposed as something separate in python-flint?Flint's
nmod
type is for "integers mod n (word size n)" whereasfmpz_mod
is for "arithmetic modulo integers". At the C level it clearly makes sense to distinguish these because the data structures are different and many functions have different call signatures and the need to manage memory makes these things not really interchangeable. In Python though there is no "word size" and integers are just integers so unless I misunderstand something the python-flint interface fornmod
andfmpz_mod
would end up being identical.Considering the notation in #53 maybe there should just be a context object called something like
fFF(p)
that would internally choose the best representation (nmod
,fmpz_mod
or anything else) without the user needing to consider which implementation to use.For integers mod n it seems like it could be easy enough to do that but then there are cases like
fq
andfq_nmod
which seem easy but could the same extend tofq_zech
or should that always be treated as separate (see #50)?See also #53 which discusses the idea of contexts to represent different types in python-flint and #54 which discusses the idea of having a low-level direct imitation of Flint's C API. Currently python-flint sort of sits in between a low and a high-level interface.
The question here is essentially whether python-flint's main interface should just be a nicer version of the low-level interface described in #54 or whether it should actually be more like the higher-level abstracted interface described in #53.
The text was updated successfully, but these errors were encountered: