about array,arange

Robert Kern robert.kern at gmail.com
Sat Nov 12 12:28:53 CET 2005

Shi Mu wrote:
> i got confused by the use of array and arange.
> arange get array and range get list, why we need the two different types?

When you're asking questions about a third-party module, it's a good
idea to mention the module. In this case you're asking about scipy_core
(hopefully) or else numarray or Numeric.

The answer to your question is that sometimes we need to get largish
arrays (not lists) of consecutive numbers quickly. array(range(N)) is
wasteful of memory and time because it has to create a list of Python
ints that are simply going to be thrown away once we're done converting
to the needed array.

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the Python-list mailing list