[Python-Dev] PEP 461 - Adding % and {} formatting to bytes

Antoine Pitrou solipsis at pitrou.net
Tue Jan 14 22:43:50 CET 2014


On Tue, 14 Jan 2014 13:07:57 -0800
Ethan Furman <ethan at stoneleaf.us> wrote:
> 
> Meaning any bytes or bytes-subtype will support the Py_buffer protocol, and this should be the first thing we try?
> 
> Sounds good.
> 
> For that matter, should the first test be "does this object support Py_buffer" and not worry about it being 
> isinstance(obj, bytes)?

Yes, unless the implementation wants to micro-optimize stuff.

> >>     - input type is numeric?
> >>       use its __xxx__ [1] [2] method and ascii-encode it (strictly)
> >
> > What is the definition of "numeric"?
> 
> That is a key question.
> 
> Obviously we have int, float, and complex.  We also have Decimal.

The question is also how do you test for them? Decimal is not a core
builtin type. Do we need some kind of __bformat__ protocol?

Regards

Antoine.




More information about the Python-Dev mailing list