[Python-Dev] str(memoryview('abc')) != 'abc' in Python 2.7
M.-A. Lemburg
mal at egenix.com
Thu Jul 15 10:03:59 CEST 2010
Nick Coghlan wrote:
> I wouldn't assume so - memoryview is meant to eventually support more
> than just 1-D views of contiguous memory (see PEP 3118), so that
> conversion doesn't seem intuitive to me.
In the example I'm passing in a single dimension contiguous memory
chunk to memoryview(), so in that case I would expect str() of that
memory chunk to return the same value and not the repr() of the
object. buffer() already works like that.
For non-contiguous memory views, the situation is less clear.
AFAIK, non-contiguous views are mostly used to provide a non-copying
view on a subset of multi-dimensional data, e.g. access to a row
or column of a matrix, so the str() should probably return a contiguous
copy of the selected data.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Jul 15 2010)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2010-07-19: EuroPython 2010, Birmingham, UK 3 days to go
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-Dev
mailing list