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
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