Skip to content

Short-circuit getcoordinates() in simple cases#54

Merged
twmacro merged 2 commits into
twmacro:masterfrom
rjyunis:speedup/getcoordinates
Jul 25, 2026
Merged

Short-circuit getcoordinates() in simple cases#54
twmacro merged 2 commits into
twmacro:masterfrom
rjyunis:speedup/getcoordinates

Conversation

@rjyunis

@rjyunis rjyunis commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Good morning, I've added a check to getcoordinates() to bypass the for-loop for "simple" calls. When csys is 0, it's significantly faster for large uset to call .loc one time and just return the values. There is probably some way to extend that logic to the rest of the routine, but for now I think this is fine.

@rjyunis rjyunis changed the title Short-circuit getcoordinates() in simple cases. … Short-circuit getcoordinates() in simple cases Jul 24, 2026
@rjyunis

rjyunis commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

In my anecdotal tests with a uset in the 10^6 gid range, this change provided a 20x speedup.

This change also adheres to the return logic of a 1-d array for a single grid, and a 2-d array for multiple gid.

@twmacro
twmacro merged commit 034fb7b into twmacro:master Jul 25, 2026
4 of 13 checks passed
@twmacro

twmacro commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Awesome! Thanks @rjyunis!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants