[SciPy-user] returning an array from weave inline
Fri Mar 30 11:18:07 CDT 2007
Yes Emanuele, that makes complete sense.
On 3/29/07, Emanuele Olivetti <email@example.com> wrote:
> Flavio Coelho wrote:
> > Thanks Fernando,
> > I thought variables converted to C were copies, so that there could not
> > an in place operation on a Python variable.
> They are copies like it is in the C way of thinking: if you pass a
> basic type (e.g. an int) to the inlined C code and modify it then
> when you are back to python there is no change in the initial variable
> you passed since just the copy was modified. If you pass something more
> (e.g. a numpy array) then you are just giving a copy of the it's reference
> (or pointer) to that function. With that reference (or copy of) you
> can access the the _original_ array and modify it. So when you are back to
> python your array _is_ changed. This mechanism allows better efficiency:
> what happens if you have a huge 2Gb array and pass it to the inline code?
> It's not desirable to make a whole copy and allocate other 2Gb or RAM...
> Anyway python itself works like that. E.g.:
> def f(a,b):
> print a,b
> print a,b
> Hope this helps,
> ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
> ITC -> since 1 March 2007 Fondazione Bruno Kessler
> SciPy-user mailing list
Flávio Codeço Coelho
registered Linux user # 386432
get counted at http://counter.li.org
"software gets slower faster than hardware gets faster"
Niklaus Wirth's law
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user