memory view over 'bytes', incorrect doc?
See original GitHub issueHi! I was trying to write a function accepting string/bytes and returning string/bytes again. I found an example of accepting strings in the documentation: https://cython.readthedocs.io/en/latest/src/tutorial/strings.html#accepting-strings-from-python-code
but it doesn’t work:
def process_byte_data(unsigned char[:] data):
length = data.shape[0]
first_byte = data[0]
slice_view = data[1:-1]
b = b'asd'
process_byte_data(b)
results in
BufferError: Object is not writable.
(Relevant topic in mailing list: https://groups.google.com/d/topic/cython-users/32CMgaLrNhc/discussion)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Obtaining pointer to python memoryview on bytes object
My problem is: because the bytes object is not writable, cython does not allow constructing a typed (cython) memoryview from it; I cannot...
Read more >Memory allocation errors can be caused by slow page file ...
Memory allocation failures can occur due to latencies that are associated with growing the size of a page file to support additional memory ......
Read more >memoryview() in Python - GeeksforGeeks
The memoryview() function allows direct read and write access to an object's byte-oriented data without needing to copy it first.
Read more >4. Built-in Types — Python 3.6.3 documentation - Read the Docs
The integer is represented using length bytes. An OverflowError is raised if the integer is not representable with the given number of bytes....
Read more >Troubleshooting Memory Leaks - Oracle Help Center
The document provides a description of the tools, command line options, and other help in analyzing a problem. The document also provides guidance...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to specify it as
const
, sincebytes
is readonly. That should probably be highlighted more in the tutorial.Absolutely. Docs PR welcome.