[pypy-svn] r52262 - pypy/branch/buffer/pypy/module/array
arigo at codespeak.net
arigo at codespeak.net
Fri Mar 7 19:06:37 CET 2008
Author: arigo
Date: Fri Mar 7 19:06:37 2008
New Revision: 52262
Modified:
pypy/branch/buffer/pypy/module/array/app_array.py
Log:
A two-liner implementation of the buffer protocol for
array objects. Obviously bad, but hard to do better
before we rewrite the whole class to interp-level.
Modified: pypy/branch/buffer/pypy/module/array/app_array.py
==============================================================================
--- pypy/branch/buffer/pypy/module/array/app_array.py (original)
+++ pypy/branch/buffer/pypy/module/array/app_array.py Fri Mar 7 19:06:37 2008
@@ -277,6 +277,9 @@
strings.append(pack(self.typecode, item))
return "".join(strings)
+ def __buffer__(self): # XXX baaaaad performance
+ return buffer(self.tostring())
+
def tounicode(self):
"""Convert the array to a unicode string. The array must be a type 'u'
array; otherwise a ValueError is raised. Use array.tostring().decode()
More information about the Pypy-commit
mailing list