Opened 6 years ago
Closed 6 years ago
#21808 closed enhancement (fixed)
Change gen.python() to return Python objects
Reported by:  Jeroen Demeyer  Owned by:  

Priority:  major  Milestone:  sage7.6 
Component:  interfaces  Keywords:  atelierpari2017 
Cc:  Luca De Feo  Merged in:  
Authors:  Vincent Delecroix  Reviewers:  Luca De Feo 
Report Upstream:  N/A  Work issues:  
Branch:  ee54f07 (Commits, GitHub, GitLab)  Commit:  ee54f071a26c63821f475d2832c7bb1fbbdd7e95 
Dependencies:  #21807  Stopgaps: 
Description (last modified by )
Currently, gen.python()
is the same as gen.sage()
which returns Sage objects. There should be a pure Python version, returning Python objects.
We implement the following conversions inside a gen_to_python
function
t_INT
>int
orlong
t_REAL
>float
t_COMPLEX
>complex
t_FRAC
> fractiont_INFINITY
>float
t_STR
>str
t_VEC
,t_COL
>list
t_MAT
>list
oflist
s
For all other types, the function raises a NotImplementedError
.
Change History (32)
comment:1 Changed 6 years ago by
Dependencies:  → #21820 

comment:2 Changed 6 years ago by
comment:3 Changed 6 years ago by
Why not:
t_REAL
>float
t_COMPLEX
>complex
t_FRAC
> fraction
t_STR
>str
t_MAT
>list
oflist
s
t_INFINITY
>float
comment:4 Changed 6 years ago by
Dependencies:  #21820 → #21807 

Keywords:  atelierpari2017 added 
comment:5 Changed 6 years ago by
Description:  modified (diff) 

Milestone:  sage7.5 → sage7.6 
comment:7 Changed 6 years ago by
Description:  modified (diff) 

comment:8 Changed 6 years ago by
Description:  modified (diff) 

comment:9 Changed 6 years ago by
Authors:  → Vincent Delecroix 

Branch:  → u/vdelecroix/21808 
Commit:  → 7fbc989969c4498f0184ef3f6144b51f53394d23 
Status:  new → needs_review 
comment:10 Changed 6 years ago by
Commit:  7fbc989969c4498f0184ef3f6144b51f53394d23 → d7ab7f60970a26c7b5881b60d447587a7fbc1433 

comment:12 Changed 6 years ago by
Commit:  d7ab7f60970a26c7b5881b60d447587a7fbc1433 → 6bd066764d0cfaab5803a14503ea416778553f21 

comment:13 Changed 6 years ago by
rebased on #21807 and all tests pass in libs/pari
, libs/cypari2
and structure/
.
comment:14 Changed 6 years ago by
Description:  modified (diff) 

comment:16 Changed 6 years ago by
Commit:  6bd066764d0cfaab5803a14503ea416778553f21 → 2c83d77107071a4659656436ab4b4beb0b634191 

comment:17 Changed 6 years ago by
Regarding TODO: this should be moved out of cypari
, I disagree. There is nothing wrong with a sage()
method importing sage
.
comment:19 Changed 6 years ago by
Commit:  2c83d77107071a4659656436ab4b4beb0b634191 → 442299f21555dfaa3cab134ae5bf7f4d600c89f5 

Branch pushed to git repo; I updated commit sha1. New commits:
442299f  21808: remove the TODO comment

comment:20 Changed 6 years ago by
Commit:  442299f21555dfaa3cab134ae5bf7f4d600c89f5 → dade42d2a7e4d56fbde0e00286c6d69ae185b812 

Branch pushed to git repo; I updated commit sha1. New commits:
dade42d  21808: remove the _eval_ method

comment:21 Changed 6 years ago by
Commit:  dade42d2a7e4d56fbde0e00286c6d69ae185b812 → 5a0311c9cf7679b42c2077b2fe2a054b835a5527 

Branch pushed to git repo; I updated commit sha1. New commits:
5a0311c  21808: remove "locals" + documentation

comment:22 Changed 6 years ago by
Commit:  5a0311c9cf7679b42c2077b2fe2a054b835a5527 → 8fb600090c0ec024e1182504776b00e6d1302a0b 

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
8fb6000  21808: remove "locals" + documentation

comment:23 Changed 6 years ago by
Commit:  8fb600090c0ec024e1182504776b00e6d1302a0b → 6ddac6c85ee496004181018e8d5dfa4121f7c424 

Branch pushed to git repo; I updated commit sha1. New commits:
6ddac6c  21808: change .python() > .sage() in sage/matrix/

comment:24 Changed 6 years ago by
Commit:  6ddac6c85ee496004181018e8d5dfa4121f7c424 → 79397fb81d76e99ca31ca3344a1fc05d710b609a 

comment:25 Changed 6 years ago by
Commit:  79397fb81d76e99ca31ca3344a1fc05d710b609a → 183588ea9ef578966fa62bd1a47db3a81fdebc29 

Branch pushed to git repo; I updated commit sha1. New commits:
183588e  21808: fix some more .python() .sage()

comment:26 Changed 6 years ago by
Description:  modified (diff) 

comment:28 Changed 6 years ago by
Branch:  u/vdelecroix/21808 → u/defeo/21808 

comment:29 Changed 6 years ago by
Commit:  183588ea9ef578966fa62bd1a47db3a81fdebc29 → ee54f071a26c63821f475d2832c7bb1fbbdd7e95 

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
8fb6000  21808: remove "locals" + documentation

6ddac6c  21808: change .python() > .sage() in sage/matrix/

01ad2d8  21808: .python() > .sage() in sage/modular/

79397fb  21808: some more .python() > .sage() conversions

183588e  21808: fix some more .python() .sage()

87b6ac3  Merge branch 't/21807/21807' into HEAD

ee54f07  Python 3 compatibility in doctests

comment:31 Changed 6 years ago by
Reviewers:  → Luca De Feo 

Status:  needs_review → positive_review 
I'm happy, Patchbot's happy, everyone's happy!
comment:32 Changed 6 years ago by
Branch:  u/defeo/21808 → ee54f071a26c63821f475d2832c7bb1fbbdd7e95 

Resolution:  → fixed 
Status:  positive_review → closed 
I would like to implement a
gentopython
function from the currentgentoobj
however very few types would be supported. Unless we allow third party Python modules such as gmpy, mpmath pythonflint, etcI guess the best solution would be to support only
t_INT
,t_VEC
,t_COL
,t_VECSMALL
and further extend the capabilities once this is moved as a Python module. What do you think?