Juraj Ivančić, 04.03.2014 16:23:
> Just for reference, it is doable in pure Python, with ctypes help
For some questionable meaning of "pure".
Stefan
--
https://mail.python.org/mailman/listinfo/python-list
On 3.3.2014. 2:27, Ian Kelly wrote:
Python 3.3 has a C API function to create a memoryview for a char*,
that can be made read-only.
http://docs.python.org/3/c-api/memoryview.html#PyMemoryView_FromMemory
I don't see a way to do what you want in pure Python, apart from
perhaps writing an el
On 03Mar2014 09:15, Juraj Ivančić wrote:
> On 3.3.2014. 1:44, Cameron Simpson wrote:
> >>ValueError: cannot hash writable memoryview object
> >
> >Have you considered subclassing memoryview and giving the subclass
> >a __hash__ method?
>
> I have, and then, when I failed to subclass it, I conside
On 3.3.2014. 2:27, Ian Kelly wrote:
Python 3.3 has a C API function to create a memoryview for a char*,
that can be made read-only.
http://docs.python.org/3/c-api/memoryview.html#PyMemoryView_FromMemory
Yes, this is probably what I'll do in absence of pure Python solution.
Thanks for th
On 3.3.2014. 1:49, Mark Lawrence wrote:
If your data is readonly why can't you simply read it as bytes in the
first place? Failing that from
http://docs.python.org/3/library/stdtypes.html#memoryview
tobytes() - Return the data in the buffer as a bytestring. This is
equivalent to calling the by
On 3.3.2014. 1:44, Cameron Simpson wrote:
ValueError: cannot hash writable memoryview object
Have you considered subclassing memoryview and giving the subclass
a __hash__ method?
I have, and then, when I failed to subclass it, I considered doing
aggregation, and make it behave byte-like. Bu
On 02Mar2014 17:55, Ian Kelly wrote:
> On Sun, Mar 2, 2014 at 5:44 PM, Cameron Simpson wrote:
> > Have you considered subclassing memoryview and giving the subclass
> > a __hash__ method?
>
> >>> class MyMemoryView(memoryview):
> ... def __hash__(self): return 42
> ...
> Traceback (most rece
On Sun, Mar 2, 2014 at 5:07 PM, Juraj Ivančić wrote:
> Is it possible to somehow 'steal' bytearray's buffer and make it a read-only
> bytes? I failed to find a way to do this, and would like to make sure.
>
> My use case is, I would expect, fairly common. I read a certain (potentially
> very large
On Sun, Mar 2, 2014 at 5:44 PM, Cameron Simpson wrote:
> Have you considered subclassing memoryview and giving the subclass
> a __hash__ method?
>>> class MyMemoryView(memoryview):
... def __hash__(self): return 42
...
Traceback (most recent call last):
File "", line 1, in
TypeError: type
On 03/03/2014 00:07, Juraj Ivančić wrote:
Is it possible to somehow 'steal' bytearray's buffer and make it a
read-only bytes? I failed to find a way to do this, and would like to
make sure.
My use case is, I would expect, fairly common. I read a certain
(potentially very large) amount of data fr
On 03Mar2014 01:07, Juraj Ivančić wrote:
> Is it possible to somehow 'steal' bytearray's buffer and make it a
> read-only bytes? I failed to find a way to do this, and would like
> to make sure.
>
> My use case is, I would expect, fairly common. I read a certain
> (potentially very large) amount
Is it possible to somehow 'steal' bytearray's buffer and make it a
read-only bytes? I failed to find a way to do this, and would like to
make sure.
My use case is, I would expect, fairly common. I read a certain
(potentially very large) amount of data from the network into a
pre-allocated byt
12 matches
Mail list logo