Help python wave simulation

Hi, I’m very new to Blender and to this forum.
I have to simulate a sea wave with this equation:

z=A*sin(k*y-w*t)

so I create with python a mesh, varying x,y coordinates values from -20 to 20 and then add z


def wavegen(dim,t):    
    vertici=[]
    faces=[]
    k=0.0403
    w=0.6283
    A=0.8216
    h=-10
    resolution=0.1
    lung=int(dim/resolution)
    for count in range(-lung,lung+1):
         z=-A*math.sin((k*count*resolution)-w*t)
         tmp=(-lung*resolution,count*resolution,z)
         vertici.append(tmp)
    for count in range(-lung,lung+1):
        z=-A*math.sin((-k*count*resolution)-w*t)
        tmp=(lung*resolution,-count*resolution,z)
        vertici.append(tmp)
    for count in range(0,4*lung+2):
        max=4*lung+1
        if count<max:
            A=count
            B=count+1
            C=max-(count+1)
            D=max-count
            tmp=(A,B,C,D)
            faces.append(tmp)
    return vertici, faces

For each t (time) I make a new mesh


#...
mymesh = bpy.data.meshes.new(name)
myobject = bpy.data.objects.new(name, mymesh)
mymesh.from_pydata(verts,[],faces)
mymesh.update(calc_edges=True)
#...


so for example if t range from 0 to 10, I have 11 objects.
To animate the scene, every frame I show only 1 object hiding the remaining


#...
invi=bpy.data.objects[name]
invi.hide=True
invi.keyframe_insert(data_path="hide", frame=frm)
#...

Long story short, it works, but when I go to render it is very very slow.
I think there is a smartest way to do that.
Is there another way to animate the mesh without create a new mesh every frame?

Nevermind I solved the problem.
I insert hide_render property so every frame it render only one mesh.


bpy.data.objects[name].hide_render=True
bpy.data.objects[name].keyframe_insert(data_path="hide_render", frame=frm)