为什么gmp不在标准库中? [英] Why gmp is not in the standard library?

查看:85
本文介绍了为什么gmp不在标准库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,


在另一个主题上,Skip写道:

是的,你是对的。从2 ** 1000开始,我很快发现了三个安全素数。使用我的版本,我看到一个安全的主要版本后放弃了等待。




这让我想到为什么Python不使用gmp因为它'小学数学

包 - 我们会得到快速的结果,很多数字类型等等。


想不出任何为什么Python实现自己的长期

数字...

你能开导我吗?


谢谢。

Miki

解决方案

mi*********@zoran.com (Miki Tebeka)写道:

大家好,

在另外一个线程Skip写道:

是的,你是对的。从2 ** 1000开始,我很快发现了三个安全素数。使用我的版本,我看到一个安全的主要版本后,我放弃了等待。



这让我想到为什么Python不能使用gmp作为它的主要数学
包 - 我们会得到快速的结果,很多数字类型等等。

没想到为什么Python实现自己的长期
数字......
你能开导我吗?




许可? IIRC,GMP是GPL。


此外,可能还有便携性。


干杯,

mwh

-

34.这个字符串是一个鲜明的数据结构,无论在哪里传递的是b $ b,都有很多重复的过程。这是一个隐藏信息的完美

工具。

- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html


Michael Hudson写道:

mi ****** ***@zoran.com (Miki Tebeka)写道:

Hello All,

在另一个线程上Skip写道:

是的,你是对的。从2 ** 1000开始,我很快发现了三个安全素数。使用我的版本,我看到一个安全的主要版本后放弃了等待。
这让我想到为什么Python不使用gmp作为它的主要数学包 - 我们'我会得到快速的结果,很多数字类型等等。

没想到为什么Python实现自己的长数字......


这个讨论部分发生在几年前,当时mxNumber是从egenix发布的
。这是一个谷歌链接:

http://mail.python.org/pipermail/pyt...il/040453.html

你能告诉我吗?



许可? IIRC,GMP是GPL。




因此是bsddb,它包含在python中。无论如何,gmp是LGPL'不会
GPL''d。

此外,可能还有便携性。




GMP非常便携,它有一个与python一起使用的大缺陷:


问:我在使用GMP计算的程序中出现了Segfault / Bus错误

数字,数十万位数。为什么?


答:GMP会在堆栈上分配大部分临时工具,而且有些机器默认情况下会为用户程序提供非常少的堆栈空间。有关如何增加堆栈分配的信息,请参阅setrlimit(2)获取

的信息。您也可以从shell更改

(使用ulimit或limit取决于shell)。你还可以使用--disable-alloca来配置--disable-alloca而不是使用malloc分配临时值

,但是这会让你的库运行速度变慢。

Brian




Miki>这让我觉得为什么Python不能使用gmp作为它的初级数学

Miki>包 - 我们会得到快速的结果,很多数字类型和很多

Miki>更多。


Miki>想不出为什么Python实现自己的长期

Miki>数字......你能开导我吗?


除了Michael Hudson提供的原因之外,我还会补充:


* Python '本地多头比gmpy长得多,或许比bmp早于gmp本身。


*从Python的长篇转换为gmpy会可能至少是一个中等重要的承诺。


Skip


Hello All,

On a different thread Skip wrote:

Yes, you''re right. Starting at 2**1000 I found three safe primes quite
quickly. Using my version I gave up waiting after seeing one safe prime
float by.



Which made me think why Python don''t use gmp as it''s primary math
package - we''ll get fast results, a lot of number types and much more.

Can''t think of any reason why Python is implementing its own long
numbers...
Can you enlighten me?

Thanks.
Miki

解决方案

mi*********@zoran.com (Miki Tebeka) writes:

Hello All,

On a different thread Skip wrote:

Yes, you''re right. Starting at 2**1000 I found three safe primes quite
quickly. Using my version I gave up waiting after seeing one safe prime
float by.



Which made me think why Python don''t use gmp as it''s primary math
package - we''ll get fast results, a lot of number types and much more.

Can''t think of any reason why Python is implementing its own long
numbers...
Can you enlighten me?



Licensing? IIRC, GMP is GPL.

Also, possibly, portability.

Cheers,
mwh

--
34. The string is a stark data structure and everywhere it is
passed there is much duplication of process. It is a perfect
vehicle for hiding information.
-- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html


Michael Hudson wrote:

mi*********@zoran.com (Miki Tebeka) writes:

Hello All,

On a different thread Skip wrote:

Yes, you''re right. Starting at 2**1000 I found three safe primes quite
quickly. Using my version I gave up waiting after seeing one safe prime
float by.
Which made me think why Python don''t use gmp as it''s primary math
package - we''ll get fast results, a lot of number types and much more.

Can''t think of any reason why Python is implementing its own long
numbers...
This discussion partly happened a couple of years ago when mxNumber was
released from egenix. Here is a google link:

http://mail.python.org/pipermail/pyt...il/040453.html
Can you enlighten me?


Licensing? IIRC, GMP is GPL.



So is bsddb and that is included with python. Anyway, gmp is LGPL''d not
GPL''d.
Also, possibly, portability.



GMP is incredibly portable, it does have one large flaw for use with python:

Q: I get a Segfault/Bus error in a program that uses GMP to calculate
numbers with several hundred thousand digits. Why?

A: GMP allocates most temporaries on the stack, and some machines give
user programs very little stack space by default. See setrlimit(2) for
information on how to increase the stack allocation. You can also change
it from the shell (using ulimit or limit depending on the shell). You
can also configure with --disable-alloca to instead allocate temporaries
using malloc, but that will make the library run somewhat slower.

Brian



Miki> Which made me think why Python don''t use gmp as it''s primary math
Miki> package - we''ll get fast results, a lot of number types and much
Miki> more.

Miki> Can''t think of any reason why Python is implementing its own long
Miki> numbers... Can you enlighten me?

In addition to the reasons Michael Hudson provided, I''ll add:

* Python''s native longs have been around much longer than gmpy, perhaps
even predating gmp itself.

* Converting from Python''s longs to gmpy would probably be at least a
moderately nontrivial undertaking.

Skip


这篇关于为什么gmp不在标准库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆