Nope, that's the way python works in general for any type other than
basic scalar types.
>>> a = [1,2,3,4]
>>> b = a
>>> b[1] = 99
>>> print a
[1, 99, 3, 4]
>>> print b
[1, 99, 3, 4]
Also the issue never comes up for types like tuples or strings because
they aren't mutable.
--bb
On 8/28/06, Sven
Charles R Harris schrieb:
> +1. I too suspect that what you have here is a reference/copy problem.
> The only thing that is local to the class is the reference (pointer),
> the data is global.
>
> Chuck
Ok, so you guys were right, turns out that my problem was caused by the
fact that a local assi
Hi,On 8/26/06, Albert Strasheim <[EMAIL PROTECTED]> wrote:
A complete code snippet that reproduces the bug would be most helpful.+1. I too suspect that what you have here is a reference/copy problem. The only thing that is local to the class is the reference (pointer), the data is global.
Chuck
--
Hi,On 8/26/06, Bill Baxter <[EMAIL PROTECTED]> wrote:
You're sure it's not just pass-by-reference semantics biting you?If you make an array and pass it to another class or function, by default they just get a reference to the same array.so e.g.:a = numpy.array
([1,2,3])some_class.set_array(a)a[1]
A complete code snippet that reproduces the bug would be most helpful.
If there is a memory corruption problem, it might show up if we run the
problematic code under Valgrind.
Regards,
Albert
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:numpy-
> [EMAIL PROTECTED] On Behalf Of
I appreciate your warnings, thanks. However, they don't seem to apply
here, or why would my described workaround work at all in that case?
Also, afaict, the affected variable is not even passed to the class
where the problematic assignment happens.
-sven
Bill Baxter schrieb:
> You're sure it's not
You're sure it's not just pass-by-reference semantics biting you?If you make an array and pass it to another class or function, by default they just get a reference to the same array.so e.g.:a = numpy.array
([1,2,3])some_class.set_array(a)a[1] = 10Then both the local 'a' and the 'a' that some_class