How to find python source code for an operator preset
following advice by brockmann, here is the code (from editmesh_tools.c in source/blender/editors/mesh)

const int clamp = em-&gt;bm-&gt;totvertsel;
int span;
int offset;

if (RNA_property_is_set(op-&gt;ptr, prop_span)) {
    span = RNA_property_int_get(op-&gt;ptr, prop_span);
    span = min_ii(span, (clamp / 2) - 1);
    calc_span = false;
}
else {
    span = clamp / 4;
    calc_span = true;
}


so it appears span is the number total vertex divided by 4. The value is then modified by another utility which extract two loops from a single one dividing geometry by angle.
Everything is done for you if you call bpy.ops.mesh.fill_grid() from a script.