DinoTools / python-overpy

Python Wrapper to access the Overpass API
https://python-overpy.readthedocs.io/
MIT License
236 stars 58 forks source link

Using lists is too slow #9

Closed dyoxyne closed 9 years ago

dyoxyne commented 9 years ago

Hello,

Thanks for the package. I used it and found that it was really slow to use the property nodes of a way element. This is basically due to the use of a list for result.nodes.

The time complexity of way.nodes is: O(number_of_nodeId * number_of_nodes). It can be done in: O(number_of_nodeId) by using a dictionary.

It can also be generalized for relations and ways.

DemersM commented 9 years ago

+1

phibos commented 9 years ago

Please have a look at the use_dict branch. The code has been merged from @dbuse and it passes all tests.