[issue17152] Array module should support boolean natively
Jesús Cea Avión added the comment: we have a -1, so I close this as rejected. I still think it is a valuable idea to pursuit. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17152] Array module should support boolean natively
Changes by Jesús Cea Avión j...@jcea.es: -- stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17152] Array module should support boolean natively
Mark Dickinson added the comment: There's already a fairly well known 3rd-party library for this: http://pypi.python.org/pypi/bitarray/ I'd be -1 on putting something like this in the standard library: the array module doesn't get enough maintenance as it is, and a packed bit array sounds like a specialist need. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17152] Array module should support boolean natively
Terry J. Reedy added the comment: You are proposing a bit array. Whether the bits are interpreted or displayed as 0/1 or f/t or False/True is secondary. The problem is that bit arrays do not fit the array model, with its minimum byte size per element of 1. There are other aspects of arrays that do not fit either. What would .itemsize() return? fractions. Fraction(1,8)? In any case, the internal implementation will be substantially different. So I suggest that the proposal be to add an array.bitarray class. The bit representation strings '0'/'1', 'f'/'t', 'False'/'True' could be parameters. Omit typecode, typecodes, amd itemsize attributes and byteswap and (to or from)string methods. The buffer_info method would need redefinition. Should (to/from)(bytes/file) use 1 byte per bit (is so, which ones) or pack 8 bits per byte? It would be sensible to add bitwise operators (~, , |, ^) on bit arrays of the same length. An implementation decision is the granularity of the internal storage (1, 2, 4, or possibly 8 bytes on 64 bit systems -- or just use 3.x ints). The insert/delete methods might be omitted, but implementation of such should be similar to the shift methods for integers, which have the same problem of moving bits between internal implementation chunks. I suspect that many have implemented versions of this in Python (as well as other languages) using bytes or ints with masks. I suggest you present the idea on python-ideas list to garner more support -- and be prepred to write a PEP for a new class. I suspect that the relative ease of using ints as bit arrays will be an argument against such an addition. That is why they have the bit operations. On the other hand, one might argue that the inclusion of bit operations acknowledges the need for bit arrays. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17152] Array module should support boolean natively
New submission from Jesús Cea Avión: Array module is used, frequently, as a convenient way of saving a lot of memory. I think we should support boolean typeobject natively. Implementation should be trivial and efficient, except methods like pop() (a bit convoluted, but doable). Opinions?. -- keywords: easy messages: 181623 nosy: jcea priority: normal severity: normal status: open title: Array module should support boolean natively type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17152] Array module should support boolean natively
Mark Dickinson added the comment: What do you mean by 'natively'? How much space do you envisage each bool taking? That is, are you suggesting a packed bool representation with 8 entries to a byte, or storing one bool per byte, or something else? -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17152] Array module should support boolean natively
Jesús Cea Avión added the comment: 1 byte = 8 bools. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17152 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com