efficient python array to numpy array conversion
Question: I get a big array (image with 12 Mpix) in the array format from the python
standard lib. Since I want to perform operations on those array, I wish to
convert it to a numpy array. I tried the following:

    
    
    import numpy
    import array
    from datetime import datetime
    test = array.array('d', [0]*12000000)
    t = datetime.now()
    numpy.array(test)
    print datetime.now() - t
    

I get a result between one or two seconds: equivalent to a loop in python.

Is there a more efficient way of doing this conversion?


Answer: 
    np.array(test)                                       # 1.19s
    
    np.fromiter(test, dtype=np.int)                      # 1.08s
    
    np.frombuffer(test)                                  # 459ns !!!
    

