On Wed, 10 Aug 2016 11:45 am, Lawrence D’Oliveiro wrote: > GvR has said “we’re all consenting adults here”. He was referring to the > “public/private/protected” access-control business that most > object-oriented languages require you to go through. But there is another > area where I think this principle applies to Python, at least in part: > low-level access to arbitrary memory.
Well, that's certainly an idiosyncratic position to take. Most people believe that high-level languages like Python should insulate the programmer from low-level details, and avoid the risk of memory corruption, buffer overflows, segmentation faults and core dumps. [...] > For the most part, Python doesn’t make it easy to allocate an object and > get access to its internal memory representation. One interesting > exception is array.array objects > <https://docs.python.org/3/library/array.html>, which have the > buffer_info() method, directly returning both the address and length of > the underlying memory block. The documentation for buffer_info() says: > > When using array objects from code written in C or C++ (the only way > to effectively make use of this information), it makes more sense to > use the buffer interface supported by array objects. > > Ah, I wish... I had a look at the documentation for the buffer interface > and memory views, and found no way to make use of them from pure Python. > Basically, the paragraph I quoted above is wrong in just about every > important detail. I don't understand. The documentation says that the ONLY way to use that information is from C or C++. You have found no other way to use that information. How is that "wrong"? How are *you* interpreting that documentation? What are you trying (and failing) to do? > So, for now, if I want to use Python-allocated memory with lower-level > APIs via ctypes, the array module remains the way to go. I really don't understand what you are trying to say. Perhaps a working code sample might help. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list