oldk1331 wrote:
>
> I completely agree with that 'construct' should not reuse
> some part of its argument.
>
> What I considered is the very large aggregate case,
> say millions of elements, takes a few hundred MB memory,
> in that case, a copy constructor will take double time and space
> than a destructive constructor.
Yes. If you are concerned with memory use do not use copy
constructor in such case. More precisely, instead of building
list and passing it to constructor build desired object
directly. Library routines avoid copies when it is easy.
OTOH we accept some inefficiency to have managable code.
In fact, it is easy to show tasks that can be done using
10 times less memory than needed by FriCAS.
Note that frequently arrays are more memory efficient
than list, so memory efficient code is likely to use
arrays. OTOH in other cases signifcant savings are
obtained by sharing substructures. But sharing works
well only if we avoid destructive operations.
Concerning idea of destructive constructor: memory is
freed by garbage collector, so all we can do to free
memory is to avoid keeping references to unneeded things.
This means that destructive constructor can give any
gain only in very special cases.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.