[Python-3000] Python, int/long and GMP

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Oct 2 20:49:07 CEST 2007


Dnia 28-09-2007, Pt o godzinie 18:58 +0200, Victor Stinner pisze:

> I don't know GMP internals. I thaught that GMP uses an hack for small
> integers.

It does not.

(And I'm glad that it does not, because it allows for super-specialized
representation of small integers where even the space for mpz_t itself
is not allocated. An GMP-internal optimization for the same cases would
be underutilized and thus wasteful.)

> I may also use Python garbage collector for GMP memory allocations
> since GMP allows to use my own memory allocating functions.

This would make linking with another library which uses GMP impossible
(unless the allocator is compatible with malloc, reentrant etc.).
Glasgow Haskell has been unfortunate to go that way.

> GMP also has its own reference counter mechanism :-/

It does not.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/



More information about the Python-3000 mailing list