structura @ctypes que contiene matrices

Estoy tratando de usarctypes. Estoy interesado en manipular estructuras C que contengan matrices. Considera lo siguientemy_library.c

#include <stdio.h>


typedef struct {

    double first_array[10];
    double second_array[10];

} ArrayStruct;


void print_array_struct(ArrayStruct array_struct){

    for (int i = 0; i < 10; i++){
        printf("%f\n",array_struct.first_array[i]);
    }

}

y supongamos que lo he compilado en una biblioteca compartidamy_so_object.so Desde Python puedo hacer algo como esto

import ctypes
from ctypes import *

myLib = CDLL("c/bin/my_so_object.so")


class ArrayStruct(ctypes.Structure):
    _fields_ = [('first_array', ctypes.c_int * 10), ('second_array', ctypes.c_int * 10)]

    def __repr__(self):
        return 'ciaone'


myLib.print_array_struct.restype = None
myLib.print_array_struct.argtype = ArrayStruct

my_array_type = ctypes.c_int * 10
x1 = my_array_type()
x2 = my_array_type()

a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

x1[0:9] = a[0:9]

a = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

x2[0:9] = a[0:9]

print(my_array_type)
>>> <class '__main__.c_int_Array_10'>

print(x1[2])
>>> 3

print(x2[2])
>>> 13

x = ArrayStruct(x1, x2)

print(x.first_array[0:9])
>>> [1, 2, 3, 4, 5, 6, 7, 8, 9]

Hasta ahora todo bien: he creado los tipos correctos y todo parece funcionar bien. Pero entonces

myLib.print_array_struct(x)
>>> 0.000000
>>> 0.000000 
>>> 0.000000
>>> 0.000000
>>> 0.000000
>>> 0.000000
>>> 0.000000
>>> 0.000000
>>> 0.000000
>>> 0.000000

Claramente me falta algo. LosArrayStruct type se reconoce (de lo contrario, la llamadamyLib.print_array_struct(x) arrojaría un error) pero no se inicializó correctamente.

Respuestas a la pregunta(1)

Su respuesta a la pregunta