Many newbie questions regarding python
Grant Edwards
invalid at invalid.invalid
Fri Oct 8 13:13:03 EDT 2010
On 2010-10-08, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2010-10-07, Rog??rio Brito <rbrito at ime.usp.br> wrote:
>
>> If possible, I would like to simply declare the list and fill it
>> latter in my program, as lazily as possible (this happens notoriously
>> when one is using a technique of programming called dynamic
>> programming where initializing all positions of a table may take too
>> much time in comparison to the filling of the array).
>
> At first you say you want a list, later you say you want an array.
> They're two different things. Arrays are variable-length and can be
> heterogeneous.
I meant _Lists_ are fixed-length and homogeneous
> If what you really want is a fixed-length, homogeneous array, then
> use an array instead of a list:
>
> http://docs.python.org/library/array.html
Actually, that's not the right link either. I was thinking more of
NumPy arrays, where you can create an arbitrary sized homogeneous
array of a desired type (either uninitialized or filled with zeros or
ones):
http://www.scipy.org/Tentative_NumPy_Tutorial#head-d3f8e5fe9b903f3c3b2a5c0dfceb60d71602cf93
If you're crunching so many numbers that initializing a list is
a problem, then you probably ought to be using NumPy.
--
Grant Edwards grant.b.edwards Yow! for ARTIFICIAL
at FLAVORING!!
gmail.com
More information about the Python-list
mailing list