Thanks a lot,
So, apparently it is possible to use a re bytes pattern to search through array.array('u') and it works as well for numpy.chararray.
However, I suppose that for doing this you need to have knowledge of the internal encoding, because re.search will actually compare bytes (from the pattern) to unicode chars (from the array). So, the bytes have to be utf32-encoded strings, I suppose.
Currently I have not enough knowledge of how Python strings are implemented. I'm convinced that it's a good thing to have mutable strings, but I guess it could indeed be hard to implement.
2015-05-08 22:46 GMT+02:00 Chris Barker firstname.lastname@example.org:
On Fri, May 8, 2015 at 5:50 AM, Stefan Behnel email@example.com wrote:
ISTM that your best bet is currently to look for a suitable module on PyPI that implements mutable character arrays. I'm sure you're not the only one who needs something like that. The usual suspect would be NumPy, but there may be smaller and simpler tools available.
Numpy does have mutable character arrays -- and the Unicode version uses 4bytes per char, regardless of platform (and so should array.array!)
But I don't think you get much of any of the features of strings, and I doubt that the re module would work with it.
A "real" mutable string type might be pretty nice to have , but I think it would be pretty hard to d to get it to do everything a string can do. (or maybe not -- I suppose you could cut and paste the regular string cdce, and simply add the mutable part....)
Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Python-ideas mailing list Pythonfirstname.lastname@example.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/