Re: [Python-Dev] Adding bytes.frombuffer() constructor to PEP 467

2017年1月06日 14:36:11 -0800

On Fri, Jan 6, 2017 at 4:43 PM, Serhiy Storchaka <[email protected]>
wrote:
> Compare these two calls:
>>
>> from array import array
>>>>> bytes(array('h', [1, 2, 3]))
>>>>>
>>>> b'\x01\x00\x02\x00\x03\x00'
>>
>> and
>>
>> bytes(array('f', [1, 2, 3]))
>>>>>
>>>> b'\x00\x00\x80?\x00\x00\x00@\x00\x00@@'
>>
>
> I don't see a difference.
Hmm indeed. Doesn't this contradict the documentation?
>>> help(bytes)
..
class bytes(object)
 | bytes(iterable_of_ints) -> bytes
 | bytes(string, encoding[, errors]) -> bytes
 | bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
..
This suggests that iterable_of_ints is tried first.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to