[Python] Is it possible to create numpy array in shared_memory using custom dtypes?

Discussão em 'Python' iniciado por Stack, Junho 20, 2025.

  1. Stack

    Stack Membro Participativo

    I can succesfully create numpy arrays with simple dtypes (int32 etc). But when i try to use something like :

    b_shared_memory = shared_memory.SharedMemory(create=True, name = "test235", size = 100_000)
    my_dtype = [('name', 'U10'), ('age', 'i4'), ('weight', 'f4')]
    x = np.array([('Rex', 9, 81.0), ('Fido', 3, 27.0)], dtype=my_dtype, buffer=b_shared_memory.buf)


    it returns an error:


    TypeError: array() got an unexpected keyword argument 'buffer'
    ​

    I have tried different dtypes combinations, but when its heterogeneous it always fails

    Continue reading...

Compartilhe esta Página