fix(abstract): stop relying on Cython resolving __NAME from class scope - #761
Open
mario4tier wants to merge 1 commit into
Open
fix(abstract): stop relying on Cython resolving __NAME from class scope#761mario4tier wants to merge 1 commit into
mario4tier wants to merge 1 commit into
Conversation
Cython emitted 58 warnings, all of the form Global name __PANDAS_SERIES matched from within class scope in contradiction to Python 'class private name' rules. This may change in a future release. The Function class reads seven module globals whose leading double underscore makes them mangling-eligible, so Python's own rules say those references should resolve to _Function__PANDAS_SERIES and fail. Cython resolves them to the module global instead and warns that it may stop. Dropping one underscore makes the code mean what it already did. The seven are private by every convention -- absent from __all__, undocumented -- and __TA_FUNCTION_NAMES__ is untouched: its trailing underscores put it outside the mangling rule. tools/generate_stream.py referenced them too, so _stream.pxi is regenerated. Nothing else moves. dir() of talib, talib._ta_lib, talib.abstract and talib.stream differs only by those seven names, and the generated C, normalised for the rename, differs only in the interned string table -- no function body, no ABI, no code path.
Member
|
👍 |
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.
Cython emits 58 warnings on every build of this repo, all one kind:
The
Functionclass reads seven module globals whose leading double underscoremakes them mangling-eligible. Python's own rules say those references should
resolve to
_Function__PANDAS_SERIESand raiseNameError; Cython resolves themto the module global instead, and warns that it may stop doing so. Dropping one
underscore makes the code mean what it already does.
__PANDAS_SERIES__PANDAS_DATAFRAME__POLARS_SERIES__POLARS_DATAFRAME__ARRAY_TYPES__INPUT_ARRAYS_TYPES__INPUT_PRICE_SERIES_DEFAULTS__TA_FUNCTION_NAMES__— trailing underscores put it outside the mangling rule, and it is publictools/generate_stream.pyreferenced them too, sotalib/_stream.pxiisregenerated. Three hanging-indent blocks re-aligned by one column.
Cython warnings: 58 → 0. gcc: 0 before, 0 after.
Nothing else moves
dir()oftalib,talib._ta_lib,talib.abstractandtalib.stream, plusFunction.info/.parameters/.function_flags, diffed before and after:the entire difference is those seven names in
talib._ta_lib._ta_lib.c, regenerated with the pinned Cython 3.2.8 andnormalised for the rename, differs in 38 lines — all of them the interned
string table: the packed identifier blob, its length index, the
content-addressed
__pyx_kp_b_*macro names, and the byte count(
111563→111555). No function body, no ABI, no code path, so performanceis identical by construction.
python-dev.py checkgreen on all four steps, including"regenerating must change nothing" and the no-Cython sdist build.
The one thing that technically changes for an outside caller is that
talib._ta_lib.__PANDAS_SERIESno longer exists. It is dunder-prefixed, absentfrom
__all__and undocumented — private by every convention — but it is a namethat existed before.