On Wed, 9 Dec 2015, paul zimmermann wrote:

mpz_export() exports an integer to some allocated array. For saving huge
integers to a file, this is not optimal since one has first to allocate a
huge array in memory, "export" the mpz_t to that array, and then copy that
array to memory.

Can't you use mmap for that? (not arguing against your interface, just wondering)

Would it be possible to have a function that exports directly to a file
(and of course the corresponding import function)?

void mpz_export_file (FILE *f, mpz_t op);
void mpz_import_file (mpz_t op, FILE *f);

One could imagine a format where several numbers can be exported in the same
file:

  f = fopen ("toto", "w");
  mpz_export_file (f, a);
  mpz_export_file (f, b);
  mpz_export_file (f, c);
  fclose (f);
  ...
  f = fopen ("toto", "r");
  mpz_import_file (a, f);
  mpz_import_file (b, f);
  mpz_import_file (c, f);
  fclose (f);

--
Marc Glisse
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to