[Cython] bint and autodoc signatures

Robert Bradshaw robertwb at gmail.com
Tue Apr 16 23:57:51 CEST 2013


On Sun, Apr 14, 2013 at 2:49 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Nikita Nemkin, 14.04.2013 11:33:
>> Arguments, return values and properties of type 'bint'
>> appear as 'int' in autogenerated signatures.
>>
>> This is very confusing for the end user and logically wrong.
>> (For one thing, bint and int handle input arguments differently:
>> bint accepts pretty much any Python object, while int requries
>> something numeric.)
>
> +1
>
>
>> Would it be acceptable to change bint display presentation
>> to 'bool' ?
>>
>> Note: other primitive types (short, int, float, long long etc)
>> don't have this problem, because they are all numeric
>> and coerce to/from Python numerics in an obvious way.
>
> The problem I see with "bool" is that it would still be different from,
> say, "list" or "MyExtType". Where the latter only accept that type and
> reject anything else with a TypeError, "bool" would accept any object and
> do a conversion instead. So "bool x" isn't correct either.
>
> I'm also not sure if "bint" is a good idea as normal Python users won't
> know it, so it's just as confusing as "int".

But it would encourage users to look it; they wouldn't assume they
know what it means.

> That being said, I guess I would find it less confusing to read
>
>    "def func(x : bool)"
>
> than
>
>    "def func(bool x)"
>
> as signature description in a docstring. So maybe that's the way to go
> eventually.

Much better than int. It's not that bad if the documented signature is
a bit stricter than reality, especially as the coercion is obvious.

- Robert


More information about the cython-devel mailing list