#28024 closed Cleanup/optimization (fixed)
GEOSCoordSeq performance could be improved significantly by avoiding superfluous checks
Reported by: | Sergey Fedoseev | Owned by: | Sergey Fedoseev |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
For proof of concept I added reworked tuple
version as tuple_fast
property.
In [14]: ls = LineString([(x, x) for x in range(1000)]) In [15]: %timeit ls.tuple 10 loops, best of 3: 43.5 ms per loop In [16]: %timeit ls.tuple_fast 10 loops, best of 3: 16.8 ms per loop
Change History (10)
comment:1 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:8 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:9 by , 8 years ago
Another related PR for LineString.__init__()
optimization.
Benchmark:
python -mtimeit -s "from django.contrib.gis.geos import LineString" "LineString([(x, x) for x in range(1000)])"
31.4 msec => 13.3 msec per loop
Note:
See TracTickets
for help on using tickets.
PR
Here's benchmarks:
python -mtimeit -s "from django.contrib.gis.geos import LineString as LS; ls = LineString([(x, x) for x in range(1000)])" "ls.tuple"
42.3 msec => 15.2 msec per loop
python -mtimeit -s "from django.contrib.gis.geos import LineString; ls = LineString((0, 0), (1, 1))" "ls[0]"
51.7 usec => 42.4 usec per loop
python -mtimeit -s "from django.contrib.gis.geos import LineString; ls = LineString((0, 0), (1, 1))" "ls[0] = (0, 0)"
62.4 usec => 51.4 usec per loop