Shapely 1.7.a2 and newer versions slow down
See original GitHub issueHi, 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (18 by maintainers)
Top Results From Across the Web
Shapely 1.7.a2 and newer versions slow down #847 - GitHub
I see a 50% slowdown. The wheels for 1.6.4.post2 include GEOS 3.6.2. The wheels for 1.7.0 include GEOS 3.8.0. It is possible that...
Read more >Fix for Shapely's GEOS library loading bug in 1.7a2
This changes everything. The problem that has bedeviled shapely users is caused by using dlopen to load a library that's already been loaded....
Read more >The Shapely User Manual — Shapely 2.0.0 documentation
This document explains how to use the Shapely Python package for ... New in Shapely 1.7.1 ... The individual coordinates are copied into...
Read more >Shapely Documentation - Read the Docs
Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. It is using the widely deployed ...
Read more >The Shapely User Manual - Projects
Abstract: This document explains how to use the Shapely Python package for computational geometry. Introduction ... New in version 1.2.14.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.