__peter__ at web.de
Thu Mar 5 12:54:39 CET 2009
> Il Thu, 05 Mar 2009 10:46:58 +0100, Peter Otten ha scritto:
>> mattia wrote:
>>>> Note how get_roulette_wheel() is now completeley independent of the
>>>> concrete problem you are using it for.
>>> Ok, but also a lot more memory consuming ;-)
>> I don't think so. Python references objects; therefore the list
>> does not consume more memory than
Oops, should have been less.
>> Or did you have something else in mind?
> Ok, understood. So if I have e.g. [[200 elements]]*N, then I'll have N
> pointers to the same location of my seq, right?
Right. You can verify this with
>>> v = 
>>> items = [v]*5
>>> v = 42
[, , , , ]
which often surprises newbies.
More information about the Python-list