diff options
author | Oscar Benjamin <oscar.j.benjamin@gmail.com> | 2022-09-25 09:09:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-25 09:09:50 (GMT) |
commit | 817fa28f81eed43539fad2c8e696df954afa6ad7 (patch) | |
tree | d1896ba43aa0978a3c9943b294c51712f1a3f39a /Python/symtable.c | |
parent | ea4be278fa6123d1f78c1fd556d79b311cd59f96 (diff) | |
download | cpython-817fa28f81eed43539fad2c8e696df954afa6ad7.zip cpython-817fa28f81eed43539fad2c8e696df954afa6ad7.tar.gz cpython-817fa28f81eed43539fad2c8e696df954afa6ad7.tar.bz2 |
gh-90716: Refactor PyLong_FromString to separate concerns (GH-96808)
This is a preliminary PR to refactor `PyLong_FromString` which is currently quite messy and has spaghetti like code that mixes up different concerns as well as duplicating logic.
In particular:
- `PyLong_FromString` now only handles sign, base and prefix detection and calls a new function `long_from_string_base` to parse the main body of the string.
- The `long_from_string_base` function handles all string validation and then calls `long_from_binary_base` or a new function `long_from_non_binary_base` to construct the actual `PyLong`.
- The existing `long_from_binary_base` function is simplified by factoring duplicated logic to `long_from_string_base`.
- The new function `long_from_non_binary_base` factors out much of the code from `PyLong_FromString` including in particular the quadratic algorithm reffered to in gh-95778 so that this can be seen separately from unrelated concerns such as string validation.
Diffstat (limited to 'Python/symtable.c')
0 files changed, 0 insertions, 0 deletions