numarray.array can be VERY slow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edward C. Jones

    #1

    numarray.array can be VERY slow

    #! /usr/bin/env python

    """Should this program take 4.3 seconds to run? I have a Linux PC with
    an AMD Athlon XP 2000+ chip (1.7Gh). I use Python 2.4.1 and numarray
    1.2.3, both compliled from source."""

    import time, numarray
    from numarray.numeri ctypes import *

    nested = []
    for i in range(8):
    inner = []
    for j in range(8):
    inner.append(nu marray.ones((25 6,256), Float64))
    nested.append(i nner)
    t = time.clock()
    arr = numarray.array( nested)
    print time.clock() - t
  • ChinStrap

    #2
    Re: numarray.array can be VERY slow

    Yes because that is a bad way to things. There is no reason to be
    working with a list when it could be done directly with numarray.

    Comment

    • Steven Bethard

      #3
      Re: numarray.array can be VERY slow

      Edward C. Jones wrote:[color=blue]
      > #! /usr/bin/env python
      >
      > """Should this program take 4.3 seconds to run? I have a Linux PC with
      > an AMD Athlon XP 2000+ chip (1.7Gh). I use Python 2.4.1 and numarray
      > 1.2.3, both compliled from source."""
      >
      > import time, numarray
      > from numarray.numeri ctypes import *
      >
      > nested = []
      > for i in range(8):
      > inner = []
      > for j in range(8):
      > inner.append(nu marray.ones((25 6,256), Float64))
      > nested.append(i nner)
      > t = time.clock()
      > arr = numarray.array( nested)
      > print time.clock() - t[/color]

      As mentioned, this has nothing to do with numarray, and everything to do
      with your inexplicable use of lists. Why don't you just write this as:

      arr = numarray.ones(( 8, 8, 256, 256), Float64)

      ??

      STeVe

      Comment

      Working...