import numpy as np from pymatgen.core import Structure, Lattice from pymatgen.optimization.neighbors import find_points_in_spheres from timeit import Timer strctr = Structure( Lattice.cubic(1.0), ['X'], [[0.0,0.0,0.0]] ) strctr.make_supercell(2) #find_points_in_spheres(strctr.cart_coords,strctr.cart_coords,1.5,np.array(strctr.lattice.pbc).astype(np.int64),strctr.lattice.matrix) reps, nums = 1000, 10000 print('fastest out of {} runs with {} calls each: {:.5e}s'.format( reps, nums, min( Timer( 'find_points_in_spheres(strctr.cart_coords,strctr.cart_coords,1.5,np.array(strctr.lattice.pbc).astype(np.int64),strctr.lattice.matrix)', globals=globals() ).repeat(repeat=reps,number=nums) ) ) )