This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jgschaefer
Recipients jgschaefer
Date 2017-05-16.14:58:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1494946731.18.0.80959187038.issue30379@psf.upfronthosting.co.za>
In-reply-to
Content
When creating a multiprocessing Array equivalent for unsigned chars, eg from a numpy.uint8 array, the first argument: typecode_or_type must be specified as a one character string, if a typecode is used the method raises a TypeError.

>>> import numpy as np, multiprocessing as mp, ctypes
>>> arr = np.array(range(10), dtype=np.uint8)
>>> arr
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8)
>>> mp.Array("B", arr)
<SynchronizedArray wrapper for <multiprocessing.sharedctypes.c_ubyte_Array_10 object
>>> mp.Array(ctypes.c_char, arr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/multiprocessing/__init__.py", line 260, in Array
    return Array(typecode_or_type, size_or_initializer, **kwds)
  File "/usr/lib/python2.7/multiprocessing/sharedctypes.py", line 120, in Array
    obj = RawArray(typecode_or_type, size_or_initializer)
  File "/usr/lib/python2.7/multiprocessing/sharedctypes.py", line 94, in RawArray
    result.__init__(*size_or_initializer)
TypeError: one character string expected

This contrasts with behavior exhibited with other types:
>>> farr = np.array(range(10), dtype=np.float)
>>> mp.Array(ctypes.c_double, farr)
<SynchronizedArray wrapper...

thanks, John
History
Date User Action Args
2017-05-16 14:58:51jgschaefersetrecipients: + jgschaefer
2017-05-16 14:58:51jgschaefersetmessageid: <1494946731.18.0.80959187038.issue30379@psf.upfronthosting.co.za>
2017-05-16 14:58:51jgschaeferlinkissue30379 messages
2017-05-16 14:58:50jgschaefercreate