Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: minimize overhead when returning objects from procedures
PostPosted: Thu Oct 10, 2013 12:35 pm 
What is a reasonable method in Singular ( less copying, less memory usage footprint )
to return rings and other objects from procedures
if there are several calling levels

- use return()
or
- update a passed list reference parameter?
or
- < put your approach here>


Report this post
Top
  
Reply with quote  
 Post subject: Re: minimize overhead when returning objects from procedures
PostPosted: Fri Oct 11, 2013 11:32 am 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
For usual types: it depends.
The time consuming operations are the same in nature and count
(clean up the old content, move the new one to the destination)
if return is compared to reference.

For ring/qring reference should not be used: there are special rules for rings which do not apply for references!

If you are looking for the fastest method with minimal memory foot print,
the construction of the object as global one may be the best method but this has other negative aspects.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: there are special rules for rings
PostPosted: Mon Oct 14, 2013 3:40 pm 
hannes wrote:
For ring/qring reference should not be used: there are special rules for rings which do not apply for references!



Could you step a little bit more into detail:
which specials rules for rings do not apply when using references?

If that is really so bad, could this be prevented by the language itself?



Jack


Report this post
Top
  
Reply with quote  
 Post subject: Re: minimize overhead when returning objects from procedures
PostPosted: Tue Oct 15, 2013 9:47 am 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
special rules for ring/qring:
- assignment does not copy
- nameof(basering) is always a local variable name even if defined in another procedure
- if there are several names for the current barering, removing nameof(basering)
sets nameof(basering) to one of the others (so nameof(basering is always defind as
long as there is any basering)

Jack wrote: If that is really so bad, could this be prevented by the language itself?
No, it is like converting module to matrix and vice versa: quite useful and sometimes necessary but should not be done too often.
Or like shooting yourself in the foot:: sometimes useful, one can still walk, but generally
not recommended.

And: reference is an experimental feature: it can/will be removed/changed/renamed etc.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 10:56 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group