Session.get_libgmt_func: Let restype default to C int type and use None for void - #4859
Open
seisman wants to merge 1 commit into
Open
Session.get_libgmt_func: Let restype default to C int type and use None for void#4859seisman wants to merge 1 commit into
seisman wants to merge 1 commit into
Conversation
- Read the shared library directly from the module-level '_libgmt' instead of lazily copying it onto 'self._libgmt', which nothing ever reassigned. - Default 'restype' to 'ctypes.c_int' (already ctypes' default) so that passing 'restype=None' means a void return, as it does in ctypes. All 17 call sites pass 'restype' explicitly, so behavior is unchanged. - Fix the 'restype' docstring: "the input returned" -> "the value returned", and move its type into the signature to match the other parameters. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies the
Session.get_libgmt_funcand fixes a minor issue:self._libgmtis assigned but not used. It was useful in old versions, but not needed after we load the gGMT library globally after Improve performance by avoiding loading the GMT library repeatedly #2930.ctypesassumes function return the Cinttype (xref: https://docs.python.org/3/library/ctypes.html#return-types), and settingrestype=Noneis equivalent to settingrestype=ctp.c_void_p(xref: https://docs.python.org/3/library/ctypes.html#return-types). However, inSession.get_libgmt_func,restype=Nonemeans not to changerestype, making the behavior inconsistent with thectypes's default behavior. This PR fixes it. It doesn't break anything, mainly because we userestype=ctp.c_void_pwhen calling this method.Detected and fixed by Claude; Reviewed by @seisman.