Terry Reedy wrote: > If orig_data were mutable (the new buffer, as proposed in the PEP), would > not > > for i in range(len(orig_data)): > orig_data[i] &= 0x1F > > do it in place? (I don't have .0a1 to try on the current bytes.)
Good catch! Python 3.0a1 (py3k:58282, Sep 29 2007, 15:07:57) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 >>> orig_data = b"abc" >>> orig_data b'abc' >>> for i in range(len(orig_data)): ... orig_data[i] &= 0x1F ... >>> orig_data b'\x01\x02\x03' It'd be useful and more efficient if the new buffer type would support the bit wise operations directly: >>> orig_data &= 0x1F TypeError: unsupported operand type(s) for &=: 'bytes' and 'int' >>> orig_data &= b"\x1F" TypeError: unsupported operand type(s) for &=: 'bytes' and 'bytes' Christian _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com