Richard Oudkerk added the comment: > I think that's a useless precaution. The bytes object cannot "leak" > since you are using PyMemoryView_FromMemory(), which doesn't know about > the original object.
The bytes object cannot "leak" so, as you say, checking that refcount is pointless. But the view might "leak", and since it does not own a reference to the base object we have a problem: we can't deallocate the bytes object for fear of breaking the view. It looks like objects returned by PyMemoryView_FromMemory() must never be allowed to "leak", so I am not sure there are many circumstances in which PyMemoryView_FromMemory() is safe to use. Perhaps using PyBuffer_FillInfo() and PyMemory_FromBuffer() would keep alive the bytes object while the view is alive, without letting the bytes object "leak". > Out of curiousity, have you done any benchmarks? No. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15903> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com