shapely: Shapely 1.7.a2 and newer versions slow down
Hi, I’m working on a project using Shapely (currently 1.6.4.post2), and I tried to update my version of Shapely. However, I noticed a huge performance decrease using the most recent release.
After a quick investigation, I noticed this problem appears for all version of Shapely >= 1.7a2.
Steps to reproduce the problem.
Example :
from shapely.geometry import Polygon
import shapely
import time
p1 = Polygon([[0,0],[5,0],[5,5],[0,5]])
p2 = Polygon([[0,0],[5,0],[5,5],[0,5]])
t1 = time.time()
for i in range(10000):
p1.difference(p2)
print('Execution time :',time.time()-t1,'seconds')
This small piece of code runs in ~0.6 second on my computer using older versions (<=1.7a1). Using 1.7a2 and newer versions of Shapely, this same code runs in 2.6 seconds.
Operating system
Fedora 30
Shapely version and provenance
Versions >= 1.6.4.post2 installed with pip. I’m using python 3.7.5.
This might be related to #834
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (18 by maintainers)
I’ve tested some new wheels that incorporate these changes to the GEOS build https://github.com/shapely/shapely-wheels/commit/df1f48c8eaf677d7a5af5a47a414e1d71bb44eec and see this:
I’m going to close this issue. There’s no performance regression in Shapely that I can see. If there is one in GEOS related to simple polygon differences, it only seems to occur in unoptimized builds.
When we publish wheels for shapely 1.7.1, users can expect some performance boosts.
That said, the optimization focus is usually towards improved performance of expensive operations. Possible that newer versions are slower when taking the difference of two squares.