[issue43376] Add PyComplex_FromString

Brandt Bucher report at bugs.python.org
Tue Mar 2 14:49:51 EST 2021


New submission from Brandt Bucher <brandtbucher at gmail.com>:

I recently came across a case where this functionality would be quite useful (parsing complex values from delimited text files). We have PyLong_FromString and PyFloat_FromString, but no PyComplex_FromString (I can't find a reason why it might have been deliberately omitted).

I *think* the best current workaround is to use sscanf to parse out two floats, then feed that to PyComplex_FromDoubles, which is non-trivial.

Do others support this addition? I imagine we would just use something similar to the _Py_string_to_number_with_underscores call at the end of complex_subtype_from_string in Objects/complexobject.c.

----------
components: C API
keywords: easy (C)
messages: 387958
nosy: brandtbucher
priority: normal
severity: normal
status: open
title: Add PyComplex_FromString
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43376>
_______________________________________


More information about the Python-bugs-list mailing list