On Fri, Apr 30, 2010 at 4:11 AM, Sergey Bochkanov
<sergey.bochka...@alglib.net> wrote:
> Hello, William.
>
>> In Sage we (=mostly Gonzalo Tornaria) spent an enormous amount of time
>> writing two very efficient C functions, one to convert from mpz to
>> Python ints, and one to convert back.   Yes, writing this code is a
>> lot of work.  But no, the resulting code is not slow.  Just because
>> something is hard doesn't mean "we can't do it".
>> If you want this code, I bet Gonzalo would be OK with letting you have
>> it under another license (it's GPL v2+ right now); it's not long, just
>> tricky to write.
>
> That  would  be  nice.  Currently X-MPIR is licensed under LGPL, but I
> think  that  the  same  automatic codegen technology may be applied to
> other  projects  under  different  licenses. So having this code under
> something BSD-like would be important step in Python support.

Although I'm more of a GPL (v2) type, and I wouldn't write BSD code
unless I had a very good reason, I could consider relicensing some
interface code like this.
I've actually relicensed this code to LGPL v2+ (for gmpy), but I'm not
sure I can go farther than that, since my code was based on GMP code
(itself LGPL v2+ at the time).

See the forwarded message below for details.

Best,
Gonzalo

---------- Forwarded message ----------
From: Gonzalo Tornaria <torna...@math.utexas.edu>
Date: Tue, Sep 8, 2009 at 10:58 PM
Subject: Re: mpmath and files
To: William Stein <wst...@gmail.com>
Cc: casevh <cas...@gmail.com>, mpm...@googlegroups.com


On Tue, Sep 8, 2009 at 8:54 PM, William Stein<wst...@gmail.com> wrote:
> On Tue, Sep 8, 2009 at 4:38 PM, casevh<cas...@gmail.com> wrote:
>> On Sep 7, 5:00 pm, William Stein <wst...@gmail.com> wrote:
>>> I think there is very complicated highly optimized code somewhere in Sage
>>> (http://sagemath.org) for conversion between Python longs and GMP
>>> mpz_t's.  If this is what you need, it could be dug up.
>>
>> I maintain gmpy, the Python wrapper for GMP or MPIR, and I would like
>> to look at including Sage's conversion code. I'm currently using
>> mpz_import and mpz_export and am always looking for faster code.
>>
>> Case Van Horsen
>>
>
> Hi,
>
> Look in the src and include directories here:
>
> http://sage.math.washington.edu/home/wstein/build/sage-4.1.1/devel/sage/c_lib/
>
>> Would there be any licensing issues since gmpy is LGPL2+?
>
> Yes, there is a problem since the code is licensed GPL2+.  However,
> I've cc'd the author -- Gonzalo Tornaria -- and I bet he would be
> willing to contribute a LGPL2+ version of the code to gmpy.  I
> certainly endorse that!

I can definitely contribute the mpz<-->pylong conversion code to gmpy
under LGPL2+.

You want to look at the files mpn_pylong.c and mpz_pylong.c. The high
level interface (mpz <-> pylong) is given by functions
mpz_get_pylong() and mpz_set_pylong(). There's also a function
mpz_pythonhash() which computes a python-compatible hash of mpz
integers.

The function mpz_get_pyintlong() is a variation of mpz_get_pylong()
written by David Harvey --- you should ask him about that one.

Note also that the base conversion code used in mpn_get_pylong() is
based on GMP code --- I think GMP was LGPLv2+ at the time, so it
should be fine.

Let me know if you have any issues with using this code in gmpy.

If you use the code, can you add a comment to the files along these lines:

"""
Originally written for sage (http://sagemath.org) -- if you improve
these functions, please contribute them back to sage by posting to
sage-devel@googlegroups.com or sending me an email.
"""

Best, Gonzalo

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to