A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-April/118643.html below:

[Python-Dev] [Python-checkins] Who are the decimal volunteers? Re: cpython: Resize the coefficient to MPD_MINALLOC also if the requested size is below

[Python-Dev] [Python-checkins] Who are the decimal volunteers? Re: cpython: Resize the coefficient to MPD_MINALLOC also if the requested size is below [Python-Dev] [Python-checkins] Who are the decimal volunteers? Re: cpython: Resize the coefficient to MPD_MINALLOC also if the requested size is belowStefan Krah stefan at bytereef.org
Tue Apr 10 00:06:23 CEST 2012
Jim Jewett <jimjjewett at gmail.com> wrote:
> Why is there any need for MPD_MINALLOC at all for (immutable) numbers?
> 
> I suspect that will involve fleshing out some of the memory management
> issues around dynamic decimals, as touched on here:
> http://www.bytereef.org/mpdecimal/doc/libmpdec/memory.html#static-and-dynamic-decimals

MPD_MINALLOC
------------

"In order to avoid frequent resizing operations, the global variable
 MPD_MINALLOC guarantees a minimum amount of allocated words for the
 coefficient of each mpd_t. [...]" 


So the rationale is to avoid resizing operations. The mpd_t data type
is not immutable -- I suspect no high speed library for arbitrary
precision arithmetic has an immutable data type.

PyDecObjects are immutable, but they have to be initialized at
some point. The mpd_t struct is part of a PyDecObject and is
in the position of the result operand during initialization.


All operations in _decimal.c follow the same scheme:

  /* dec contains an mpd_t with MPD_MINALLOC words. */
  dec = dec_alloc();

  /* Initialization by a libmpdec function. MPD() is the
     accessor macro for the mpd_t. */
  mpd_func(MPD(dec), x, y, ...);

  /* From here on dec is immutable */



Stefan Krah


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4