#18052: Wrap Python functions in a PARI t_CLOSURE
-------------------------------------+-------------------------------------
       Reporter:  jdemeyer           |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.6
      Component:  interfaces         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/wrap_python_functions_in_a_pari_entree_and_t_closure|  
908980802369b07209740329aca6a2f6710f6cec
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by pbruin):

 Two comments on the current implementation:
 - I think it is better to use `ulong` instead of `unsigned long`, because
 `unsigned long` may be smaller than the size of a pointer (on 64-bit
 Windows maybe?).
 - The case where the Python function returns `None` is not handled
 correctly; I propose
 {{{
 #!diff
 --- a/src/sage/libs/pari/closure.pyx
 +++ b/src/sage/libs/pari/closure.pyx
 @@@ -65,7 +65,10 @@ cdef inline GEN call_python_func_impl
 "call_python_func"(GEN* args, object py_fu
      # Call the Python function
      r = PyObject_Call(py_func, t, <dict>NULL)

 -    # Convert the result to a gen and copy it to the PARI stack
 +    # Convert the result to a GEN and copy it to the PARI stack,
 +    # treating None specially
 +    if r is None:
 +        return gnil
      return gcopy(objtogen(r).g)

  # We rename this function to be able to call it with a different
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/18052#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to