[Scilab-users] Large variables and execution speeds

Clément David clement.david at scilab-enterprises.com
Wed Feb 25 09:16:31 CET 2015


Hello Tim,

Yes, the copies are there as Scilab does not allow to pass data by
reference but only by copy.

To avoid extra copy when using tlist, you have to avoid data resize
which is really costly. When writing :

local_tlist.some_field = stuff;

There is no performance penalty if 'some_field' and 'stuff' have the
same datatype and size. Scilab will be able to simply reuse the
allocated space.

However using a tlist rhs/lhs force a copy which is not needed, using
named arguments let the interpreter avoid some copies.

For a complete bench, see the attached file.

Le mardi 24 février 2015 à 13:38 -0800, Tim Wescott a écrit :
> I have an algorithm that I'm working on that involves having large data
> sets, which I'm currently representing as tlists.  Due to the
> constraints of the algorithm, I'm doing many calls that are more or less
> of the form:
> 
> my_tlist = some_function(my_tlist);
> 
> The intent is to get the same effect that I would get if I were in C or
> C++, and wrote:
> 
> some_function(& my_structure);
> 
> or
> 
> my_class.some_function();
> 
> It appears, from the significant loss of execution speed when I do this,
> that Scilab is copying the results of the function into the "my_tlist"
> variable byte by byte.
> 
> At this writing, the only way that I can see to fix this is to invoke
> the function as:
> 
> some_function("my_tlist");
> 
> and then wherever I modify data have use an exec function, i.e., replace
> 
> local_tlist.some_field = stuff;
> 
> with
> 
> exec(msprintf("%s = stuff", local_tlist_name));
> 
> This seems clunky in the extreme.
> 
> Is there another way to do something like this that doesn't force Scilab
> to copy large chunks of data needlessly, but allows me to operate on
> multiple copies of similar tlists?
> 
> Thanks.
> 

--
Clément
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reduced.sce
Type: application/x-scilab-sce
Size: 768 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20150225/bef20675/attachment.bin>


More information about the users mailing list