[issue41377] memoryview of str (unicode)

2020-07-24 Thread Guido van Rossum
Guido van Rossum added the comment: We should not do this, it would expose internals that we need to keep private. The right approach would be to keep things as bytes. -- nosy: +gvanrossum resolution: -> wont fix stage: -> resolved status: open -> closed ___

[issue41377] memoryview of str (unicode)

2020-07-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Raymond. Also, it could not help to caught bugs when you get a string instead expected bytes object. It may "work" in tests while string is ASCII, but fail miserably on real-world non-ASCII data. -- nosy: +serhiy.storchaka _

[issue41377] memoryview of str (unicode)

2020-07-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think we can close this. AFAICT, if we exposed the raw internal object with a memory view, there would be no practical way to use the data without a user having to substantially recreate the logic already present in encode() and the other string method

[issue41377] memoryview of str (unicode)

2020-07-23 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue41377] memoryview of str (unicode)

2020-07-23 Thread Eric V. Smith
Eric V. Smith added the comment: I don't think there's a python-level api to find out the "kind", but I can't say I've looked closely. And there are no doubt problems with doing so and alternate implementations other than CPython. I'm not sure we want to expose this implementation detail, bu

[issue41377] memoryview of str (unicode)

2020-07-23 Thread jakirkham
jakirkham added the comment: Thanks for the clarification, Eric! :) Is this the sort of thing that we could capture in the `format`[1] field (like with `"B"`, `"H"`, and `"I"`[2]) or are there potential issues there? [1]: https://docs.python.org/3/c-api/buffer.html#c.Py_buffer.format [2]: ht

[issue41377] memoryview of str (unicode)

2020-07-23 Thread Eric V. Smith
Eric V. Smith added the comment: > AIUI (though I could be misunderstanding things) `str` objects do use some > kind of typed array of unicode characters (either 16-bit narrow or 32-bit > wide). It's somewhat more complicated. The string data is stored differently depending on the maximum

[issue41377] memoryview of str (unicode)

2020-07-23 Thread jakirkham
New submission from jakirkham : When working with lower level C/C++ code, the Python Buffer Protocol[1] has been immensely useful as it allows common Python `bytes`-like objects to expose the underlying memory buffer in a pointer that C/C++ code can easily work with zero-copy. In fact `memoryv