#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

 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):


         array = array('B')
         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

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