Create gridlines in Python
You can create a grid primitive and remove the faces:
import bpy
import bmesh

sce = bpy.context.scene

me = bpy.data.meshes.new(&quot;Grid&quot;)
bm = bmesh.new()
bmesh.ops.create_grid(bm, x_segments=32, y_segments=32, size=50)
bmesh.ops.delete(bm, geom=bm.faces, context=3)
bm.to_mesh(me)

ob = bpy.data.objects.new(&quot;Grid&quot;, me)
sce.objects.link(ob)
sce.update()

This will give you a grid at origin, dimension x/y 100 and with 1024 vertices.

from_pydata():

it creates primitives from verts+faces, not verts+edges

You can either pass two sequences for verts and faces, or you give it verts and edges - it should work the same.