[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you need to support only bytes and bytearray, but not other bytes-like object, this is a too special case. It is easy to write your own macros or functions that wrap existing C API. Other option -- duplicate the code and replace PyBytes_ with

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread Ori Avtalion
Ori Avtalion added the comment: My use-case is modifying existing code that supports bytes to also support bytearray. https://github.com/mongodb/mongo-python-driver/blob/9902d239b4e557c2a657e8c8110f7751864cec95/bson/_cbsonmodule.c#L1112 The buffer protocol, which I didn't know of, feels

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The unified C API already exists. It is called the buffer protocol. https://docs.python.org/3/c-api/buffer.html#buffer-related-functions -- ___ Python tracker

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread Ronald Oussoren
Ronald Oussoren added the comment: What is your use case for this? Is that something that can use the buffer API instead of these low-level APIs? -- nosy: +ronaldoussoren ___ Python tracker

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: I remove 2.7 because this branch is in bugfix mode, no new features. -- nosy: +matrixise, serhiy.storchaka, vstinner versions: -Python 2.7 ___ Python tracker

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread STINNER Victor
STINNER Victor added the comment: Stéphane: Please don't add me to the nosy list of bugs. -- ___ Python tracker ___ ___

[issue36065] Add unified C API for accessing bytes and bytearray

2019-02-21 Thread Ori Avtalion
New submission from Ori Avtalion : It would be useful to have a shared API for consuming bytes and bytearrays. At present, I need to write very similar code twice. Some existing codebases only support bytes (perhaps forgetting bytearrays exist). Adding support for bytearray would be trivial