Friday 15 August 2014

python - Cython Memoryviews -- From Array of Structs? -


I would like to fill as many copies as possible, as much as possible of the long array of strokes that I am getting from C.

If my composition is only the primary data type, then the following:

  cdef packed framework Ohh: hi lucky four ominous   

Then the following actions are correct:

  DEF MAXPOWER = 1000000 cdf oh_ hi * hi2u = & lt; Oh_he *> Mallok (shapeoff (oh_y) * MAXPOWER) cdef oh_en [:] hi2me = & lt; Oh_en [: MAXPOWER] & gt; Hi2u   

But once I change my string to hold a string:

  cdef packed structure oh_y: int lucky four ominous [10]   

Past memory casting is compiled but when runs:

  Value error: expected 1 dimension (1), got 1   

Is there an easy way to do this in the statement? I know that I can make a structured array, but the APIC, which does not allow me to allocate all the straight strokes. = "Text">

Actually, just creating a structured numerical array and then the memoryview works fine.

  cdef np.ndarray hi2u = np.ndarray (MAXPOWER,), dtype = [('lucky', 'I4'), ('inauspicious', 'A10')]) Cdf oh_ hi [:] hi2me = hi2u   

This display is very good and it saves a subsequent copy if you need data in Python. As always, the oval version is very good = P

No comments:

Post a Comment