Last active
          December 11, 2015 10:09 
        
      - 
      
- 
        Save chriswl/4584895 to your computer and use it in GitHub Desktop. 
    timing itemgetter vs. indexing
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import timeit | |
| timeit.timeit(stmt= "[a[i] for i in b]", setup = "from operator import itemgetter; import numpy as np; a = list(np.random.random(100)); b = np.random.random_integers(100, size=1000) - 1", number=1000) | |
| timeit.timeit(stmt= "itemgetter(*b)(a)", setup = "from operator import itemgetter; import numpy as np; a = list(np.random.random(100)); b = np.random.random_integers(100, size=1000) - 1", number=1000) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment