Skip to content
New issue

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

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

Already on GitHub? # to your account

PERF: Optimize point transformations #1204

Merged
merged 2 commits into from
Dec 21, 2022
Merged

Conversation

snowman2
Copy link
Member

@snowman2 snowman2 commented Dec 17, 2022

Related: #1202

In [1]: from pyproj import Transformer

In [2]: transformer = Transformer.from_crs(4326, 3857, always_xy=True)

In [3]: %timeit transformer.transform(1, 2)
4.69 µs ± 37.9 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

In [4]: %timeit transformer.transform_point(1, 2)
2.08 µs ± 20.2 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

Version in #1203:

In [5]: %timeit transformer.transform_point(1, 2)
2.99 µs ± 132 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

@codecov
Copy link

codecov bot commented Dec 17, 2022

Codecov Report

Merging #1204 (c9126d3) into main (c4cb8f0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1204   +/-   ##
=======================================
  Coverage   96.28%   96.29%           
=======================================
  Files          20       20           
  Lines        1804     1808    +4     
=======================================
+ Hits         1737     1741    +4     
  Misses         67       67           
Impacted Files Coverage Δ
pyproj/transformer.py 95.04% <100.00%> (+0.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This works great for me.

@snowman2 snowman2 force-pushed the transform_point branch 2 times, most recently from 0a04665 to 62ec762 Compare December 17, 2022 18:08
@snowman2 snowman2 force-pushed the transform_point branch 2 times, most recently from 519da77 to 03ee8f5 Compare December 20, 2022 02:29
@snowman2 snowman2 changed the title ENH: Added Transformer.transform_point PERF: Optimize point transformations Dec 20, 2022
@snowman2
Copy link
Member Author

With #1208

In [3]: transformer = Transformer.from_crs(4326, 3857, always_xy=True)

In [4]: %timeit transformer.transform(1, 2)
1.44 µs ± 38.6 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

In [5]: %timeit transformer.transform(1, 2)
1.42 µs ± 14.1 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

In [6]: %timeit transformer.transform(1, 2)
1.44 µs ± 19.1 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I get similar timings to you, and not a major slowdown for trying this before going down the other path. So, I do like this better than adding a new method, and theoretically downstream users should be able to get immediate benefits without needing to change the call sites.

@snowman2
Copy link
Member Author

I do like this better than adding a new method, and theoretically downstream users should be able to get immediate benefits without needing to change the call sites.

I agree

@snowman2 snowman2 force-pushed the transform_point branch 2 times, most recently from d0a7f4e to 5fda90a Compare December 21, 2022 03:07
@snowman2 snowman2 merged commit 39ae460 into pyproj4:main Dec 21, 2022
@snowman2 snowman2 deleted the transform_point branch December 21, 2022 04:19
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants