/doc/index.html

http://gmpy.googlecode.com/ · HTML · 198 lines · 184 code · 9 blank · 5 comment · 0 complexity · d054b67f1de2efb8b6c4c0d6d43f58a8 MD5 · raw file

  1. <HTML>
  2. <HEAD>
  3. <TITLE>Welcome to General Multiprecision PYthon
  4. </TITLE>
  5. <!--
  6. <LINK rel="stylesheet"
  7. href="http://sourceforge.net/sourceforge.css"
  8. type="text/css">
  9. -->
  10. <STYLE>
  11. body { margin-left: 30; margin-right: 30; }
  12. </STYLE>
  13. </HEAD>
  14. <BODY>
  15. <FONT SIZE=-1>
  16. Last updated on: 2008, June 22;
  17. for GMPY release: 1.04
  18. <A href="http://code.google.com/p/gmpy/">
  19. <IMG src="http://code.google.com/images/code_sm.png"
  20. width="88" height="31" border="0" alt="Go to Google Code gmpy page"></A>
  21. <br>
  22. </FONT>
  23. <H1>GMPY Project goals and strategies</H1>
  24. The General Multiprecision PYthon project (GMPY) focuses on
  25. Python-usable modules providing multiprecision arithmetic
  26. functionality to Python programmers. The project mission
  27. includes both C and C++ Python-modules (for speed) and pure
  28. Python modules (for flexibility and convenience); it
  29. potentially includes integral, rational and floating-point
  30. arithmetic in any base. Only cross-platform functionality
  31. is of interest, at least for now.
  32. <P>
  33. As there are many good existing free C and C++ libraries
  34. that address these issues, it is expected that most of the
  35. work of the GMPY project will involve wrapping, and exposing
  36. to Python, exactly these existing libraries (possibly with
  37. additional "convenience" wrappers written in Python itself).
  38. For starters, we've focused on the popular (and excellent)
  39. GNU Multiple Precision library,
  40. <A HREF="http://gmplib.org/">GMP</A>,
  41. exposing its functionality through module <b>gmpy</b>.
  42. <H1>The GMPY Module</H1>
  43. <P>
  44. Python modules older than GMPY exposes a subset of the integral-MP
  45. (MPZ) functionality of earlier releases of the GMP library. The
  46. first GMPY goal (currently nearly reached) was to develop the gmpy
  47. module into a complete exposure of MPZ, MPF (floating-point), and
  48. MPQ (rational) functionality of current GMP (release 4), as well
  49. as auxiliary functionality such as random number generation, with
  50. full support for current Python releases (2.3 and up) and the
  51. Python 'distutils' (and also support for a "C API" allowing some
  52. level of interoperation with other C-written extension modules for
  53. Python).
  54. <p>
  55. <b>Note</b>: the module's ability to be used as a "drop-in
  56. replacement" for Python's own implementation of <i>long</i>s,
  57. to rebuild Python from sources in a version using GMP, was a
  58. characteristic of the gmp-module we started from, but is
  59. <b>not</b> a target of the gmpy project, and we have no plans
  60. to support it.
  61. <P>
  62. This first GMPY
  63. module is called <b>gmpy</b>, just like the whole project.
  64. <P>
  65. The extended MP floating-point facilities of
  66. <A HREF="http://www.loria.fr/projets/mpfr/">MPFR</A>
  67. will later also be considered for inclusion in gmpy (either within
  68. the same module, or as a further, separate add-on module).
  69. [[ Rooting for MPFR to be merged with GMP so we can avoid some
  70. awkwardness (but seeing no movement on this front so far) ]].
  71. <H2>Mutability... but <u>not</u> for now</H2>
  72. Early tests have shown that supporting Python 2's "in-place
  73. operation" functionality (by making MPZ, MPF and MPQ Python objects
  74. <b>mutable</b>) would offer a substantial performance boost.
  75. <p>
  76. Despite this, widespread feeling among Python cognoscenti appears
  77. to be against exposing such "mutable numbers". As a consequence,
  78. our current aim is for a first release of GMPY without mutability,
  79. to be followed at some later time by one which will also fully
  80. support in-place-mutable versions of number objects (as well as
  81. the default immutable ones), but only when explicitly and
  82. deliberately requested by a user (who can then be presumed to know
  83. what he or she is doing). Meanwhile, caching strategies are used
  84. to ameliorate performance issues, and appear to be reasonably
  85. worthwhile (so far, only MPZ and MPQ objects are subject to this
  86. caching).
  87. <p>
  88. We've tended to solve other debatable design issues in a similar
  89. vein, i.e., by trying to work "like Python's built-in numbers" when
  90. there was a choice and two or more alternatives made sense.
  91. <H1>Project Status and near-future plans</H1>
  92. The gmpy module's current release (latest current release
  93. as of 2008/10/16: 1.04) is available for download in both
  94. source and Windows-binary form, and Mac-binary form too.
  95. gmpy 1.04 exposes all of the mpz, mpq
  96. and mpf functionality that was already available in GMP 3.1, and
  97. most of the random-number generation functionality (there are no
  98. current plans to extend gmpy to expose other such functionality,
  99. although the currently experimental way in which it is architected
  100. is subject to possible future changes).
  101. <p>
  102. On most platforms, you will need to separately procure and install
  103. the GMP library itself to be able to build and use GMPY. Note that
  104. 4.0.1 or better is needed; take care: some Linux releases come bundled
  105. with <strong>older</strong> GMP versions, such as GMP 3, and you may
  106. have to install the latest GMP version instead -- beware also of
  107. /usr/lib vs /usr/local/lib issues.
  108. <p>
  109. Please read the file "windows_build.txt" for detailed instructions on
  110. compiling GMP and GMPY using the freely available MinGW tools.
  111. <p>
  112. [[ OLD: The exception to this need is under (32-bit) Windows, where
  113. binary-accompanied releases are the norm, and builds of GMP usable
  114. with MS VC++ 6 (the main C compiler used for Python on this platform)
  115. are traditionally hard to come by.
  116. <p>
  117. We started the GMPY project using a VC++ port of GMP.LIB "just found on
  118. the net", and later a port by Jorgen Lundman, but are currently relying
  119. on other volunteers to build Windows binaries since we don't have any
  120. Windows machine any more. <a
  121. href="http://www.cs.nyu.edu/exact/core/gmp/">This site</a> does appear
  122. to offer all needed files and instructions for Windows developers who
  123. want to re-build the gmpy module from sources; the gmpy project itself
  124. just supplies a separate 'binary module' package is supplied, containing
  125. only the pre-built GMPY.PYD, for those who do <b>not</b> want to
  126. re-build from sources. ]]
  127. <p>
  128. <b>Do</b> note, however, that <b>all</b> gmpy users should download the
  129. gmpy source-package as well, as currently that is the one including
  130. <b>gmpy</b> documentation and unit-tests!
  131. <H2>Currently-open issues</h2>
  132. <p>
  133. A still-weakish point is with the output-formatting of mpf numbers;
  134. sometimes, this formatting ends up providing a few more digits than
  135. a given number's accuracy would actually warrant (a few noise digits
  136. after a long string of trailing '0' or '9' digits), particularly when
  137. the mpf number is built from a Python float -- the accuracy situation
  138. is quite a bit better when the mpf number is built from a <b>string</b>.
  139. <p>
  140. Because of this, since release 0.6, gmpy introduced an optional
  141. 'floating-conversion format string' module-level setting: if present,
  142. float-&gt;mpf conversion goes through an intermediate formatted
  143. string (by default, it still proceeds directly, at least for now);
  144. this does ameliorate things a bit, as does the better tracking done
  145. (since 0.6, with further enhancements in 0.7) of the 'requested'
  146. precision for an mpf (as opposed to the precision the underlying GMP
  147. actually 'assigns' to it); but the issue cannot yet be considered fully
  148. solved, and may well still need some design changes in the output
  149. formatting functionality.
  150. <p>
  151. Unit tests are not considered a weak point any more; the over 1000
  152. unit-tests now being run provide a decent cover of 93+% SLOC for gmpy.c,
  153. up from 72% in 0.7. The non-covered SLOCs (about 150 of gmpy.c's
  154. current 2311 executable lines out of 6205 total)
  155. are mostly disaster-tests to handle out-of-memory
  156. situations, a smattering of 'defensive
  157. programming' cases (to handle situations that 'should never happen,
  158. but'...) and some cases of the new experimental 'callbacks' facility
  159. (mostly provided for the specific use of PySymbolic, and intended to be
  160. tested by that package). We'll have to do better, eventually (presumably with
  161. some mocking approach e.g. to simulate out-of-memory situations), but, for now,
  162. this can be considered OK.
  163. <p>
  164. In the attempt to make gmpy as useful as can be for both stand-alone
  165. use, and also in the context of PySymbolic, a tad too many design
  166. decisions have been delayed/postponed by introducing module-level
  167. flags, letting us 'have it both ways' in the current
  168. gmpy 1.04; this has produced a somewhat unwieldy mix of module-level
  169. flag-setting and call-back functions. This whole area's architecture
  170. will neet to be revisited, including other such design-decisions yet.
  171. <H2>Near-future plans</h2>
  172. Future releases may have changes including: re-architecting the
  173. module-level setting functions; more elegantly formatted documentation;
  174. more timing-measurement scripts and usage-examples. Some of the
  175. currently experimental 'callbacks' will also be removed, having been
  176. proven unnecessary. All relevant GMP 4 functionality will be exposed.
  177. <p>
  178. No predictions on timing, though. gmpy 1.04 meets all current needs
  179. of the main author, so his motivation to work more on it is low:-).
  180. So, don't hold your breath (pitching in and helping it happen, on the
  181. other hand, _might_ be advisable, and will surely yield results:-).
  182. <p>
  183. <A HREF="http://code.google.com/p/gmpy/">Project page on
  184. code.google.com</A>
  185. <A href="http://code.google.com/p/gmpy/">
  186. <IMG src="http://code.google.com/images/code_sm.png"
  187. width="88" height="31" border="0" alt="Go to Google Code gmpy page"></A>
  188. </BODY>
  189. </HTML>