[Python] How to create a numpy.array from a list of floats with shared-memory with version...

Discussão em 'Python' iniciado por Stack, Março 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a numpy array from a list of floats with shared-memory such that updating the list updates the numpy array.

    import numpy as np
    lists = [[1]]
    arr = np.asarray(lists, dtype=object)
    lists[0][0] = 9999
    arr # [[1]], but I want to return 9999


    If I add copy=False, I get the error: ValueError: Unable to avoid copy while creating an array as requested.

    I am aware of byearray, but that seems to only work for ints. Is there any possible way to have the a numpy array of list of numpy floats without creating a copy?

    Continue reading...

Compartilhe esta Página