[Numpy-discussion] chararray constructor change

Alan McIntyre alan.mcintyre@gmail....
Wed Jul 9 15:35:12 CDT 2008


I'd like to make the following change to the chararray constructor.
This is motivated by some of chararray's methods constructing new
chararrays with NumPy integer arguments to itemsize, and it just
seemed easier to fix this in the constructor.

Index: numpy/numpy/core/defchararray.py
===================================================================
--- numpy/numpy/core/defchararray.py	(revision 5378)
+++ numpy/numpy/core/defchararray.py	(working copy)
@@ -25,6 +25,11 @@
         else:
             dtype = string_

+        # force itemsize to be a Python long, since using Numpy integer
+        # types results in itemsize.itemsize being used as the size of
+        # strings in the new array.
+        itemsize = long(itemsize)
+
         _globalvar = 1
         if buffer is None:
             self = ndarray.__new__(subtype, shape, (dtype, itemsize),


More information about the Numpy-discussion mailing list