#7674 NORM 8.2.0 (: Using array.array instead of numpy might be faster

Zarro Boogs per Child bugtracker at laptop.org
Mon Jul 28 08:34:47 EDT 2008


#7674: Using array.array instead of numpy might be faster
-------------------------+--------------------------------------------------
 Reporter:  benzea       |         Owner:  homunq              
     Type:  task         |        Status:  new                 
 Priority:  normal       |     Milestone:  8.2.0 (was Update.2)
Component:  sugar        |       Version:  not specified       
 Keywords:  performance  |   Next_action:  diagnose            
 Verified:  0            |     Blockedby:                      
 Blocking:               |  
-------------------------+--------------------------------------------------
 Sugar switched from using array.array to useing numpy.array for speed
 reasons (see ticket #2890 and
 http://dev.laptop.org/git?p=sugar;a=commitdiff;h=735b0cf2c8a5c85b89a0b82d4fc1f40ec6ab5d12;hp=5ebc0c8212f762025cf6f42fad040cd04cb58ebd).

 As numpy is slow to import (>5 seconds in a quick test), it might be
 faster to switch back to using array.array. The speed of the array
 creation can be improved by replacing the old loop:

 {{{
         self._array = array('B')
         for i in range(width * height):
             self._array.append(0)
 }}}

 with:

 {{{
         array = array('B')
         array.append(0)
         self._array = array * (width*height)
 }}}


 In my tests the above code took 0.21 seconds to complete. The numpy code
 is a lot faster with only 0.01 seconds. So if not many arrays are created
 it could be faster to use array instead of numpy.

 Someone could try if this makes a difference in boot time (be carefull to
 remove all numpy imports when testing, there is one in src/main.py in
 sugar.)

-- 
Ticket URL: <http://dev.laptop.org/ticket/7674>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system


More information about the Bugs mailing list