1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| >>> import random
>>> from time import time
>>>
>>> idents = range(25000)
>>> random.shuffle(idents)
>>> # petite verif
... print idents[:10]
[20527, 3454, 14104, 12341, 23876, 15896, 16088, 11081, 4679, 24899]
>>>
>>> VertexList = [ {'X':0., 'Y':0., 'VertexId':i } for i in idents ]
>>>
>>> t0=time(); VertexList.sort(key=lambda elt: elt['VertexId']);time()-t0
0.0328829288482666
>>>
>>> # autre verif
... import pprint
>>> pprint.pprint(VertexList[:10])
[{'VertexId': 0, 'X': 0.0, 'Y': 0.0},
{'VertexId': 1, 'X': 0.0, 'Y': 0.0},
{'VertexId': 2, 'X': 0.0, 'Y': 0.0},
{'VertexId': 3, 'X': 0.0, 'Y': 0.0},
{'VertexId': 4, 'X': 0.0, 'Y': 0.0},
{'VertexId': 5, 'X': 0.0, 'Y': 0.0},
{'VertexId': 6, 'X': 0.0, 'Y': 0.0},
{'VertexId': 7, 'X': 0.0, 'Y': 0.0},
{'VertexId': 8, 'X': 0.0, 'Y': 0.0},
{'VertexId': 9, 'X': 0.0, 'Y': 0.0}] |