Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyproj crs equality comparison became much slower in 3.0 #880

Closed
mityakrylov opened this issue Jul 13, 2021 · 2 comments
Closed

pyproj crs equality comparison became much slower in 3.0 #880

mityakrylov opened this issue Jul 13, 2021 · 2 comments
Labels
proj Bug or issue related to PROJ

Comments

@mityakrylov
Copy link

Code Sample, a copy-pastable example if possible

WGS = CRS4326 = pyproj.CRS('epsg:4326')

WGS == CRS4326

Problem description

Test for equality takes about ~10ms on pyproj==3.0.1 and ~10µs on pyproj==2.6.0. I measured in jupyter notebook using timeit cell magic:

%%time
WGS == CRS4326

I noticed that when function that was applied to thousands of geometries became much slower after pyproj upgrade. And the main reason was increased time for crs comparison.

Is this expected behavior in pyproj==3.0.1? If yes, what is better way to test crs for equality? Maybe something like this:

WGS.srs == CRS4326.srs

?

Environment Information

for pyproj==3.0.1:

pyproj info:
    pyproj: 3.0.1
      PROJ: 7.2.1
  data dir: /home/user/envs/bp/lib/python3.6/site-packages/pyproj/proj_dir/share/proj
user_data_dir: /home/user/.local/share/proj

System:
    python: 3.6.9 (default, Jul  3 2019, 15:36:16)  [GCC 5.4.0 20160609]
executable: /home/user/envs/bp/bin/python3
   machine: Linux-4.15.0-107-generic-x86_64-with-Ubuntu-16.04-xenial

Python deps:
       pip: 20.0.2
setuptools: 46.1.3
    Cython: None

for pyproj==2.6.0:

pyproj info:
    pyproj: 2.6.0
      PROJ: 6.3.1
  data dir: /home/user/envs/bp/lib/python3.6/site-packages/pyproj/proj_dir/share/proj

System:
    python: 3.6.9 (default, Jul  3 2019, 15:36:16)  [GCC 5.4.0 20160609]
executable: /home/user/envs/bp/bin/python
   machine: Linux-4.15.0-107-generic-x86_64-with-Ubuntu-16.04-xenial

Python deps:
       pip: 20.0.2
setuptools: 46.1.3
    Cython: None

Installation method

pip3 install pyproj==3.0.1
pip3 install pyproj==2.6.0
@snowman2
Copy link
Member

I wonder if using PROJ 8.1+ speeds things up: OSGeo/PROJ#2738 (comment)

@snowman2 snowman2 added proj Bug or issue related to PROJ and removed bug labels Jul 17, 2021
@snowman2
Copy link
Member

Looks like it has been resolved with PROJ 8.1+:

python -m timeit -s "import pyproj; crs = pyproj.CRS(4326)" "assert crs == crs"
100000 loops, best of 5: 3.38 usec per loop

Version information:

pyproj: 3.1.0
PROJ: 8.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proj Bug or issue related to PROJ
Projects
None yet
Development

No branches or pull requests

2 participants