# How to spin a curve to create a surface using python script?

I am new to Blender. I need to spin a curve around the z-axis to create an arbitrary surface as shown below:

I have successfully implemented spinning using bmesh. It seems I have to create an object possessing mesh as defined in bmesh. Is there any other way to do this spinning process using python script? My current code to generate curve is similar to [Ref]. Thank you.

EDIT1: If anyone can do this without using screw? Or how to use screw modifier to spin around an arbitrary axis in python script?

Screw the curve too.

Similarly to creating with bmesh

import bpy

def poly(x):
return   0.2 * x * x - x + 3

cu = bpy.data.curves.new("poly", 'CURVE')
cu.dimensions  = '3D'
bez = cu.splines.new('BEZIER')
pts = [(poly(z), 0, z) for z in range(10)]
flat = [p for pt in pts for p in pt]
s = cu.splines.new('BEZIER')
# set the points in one fell swoop
s.bezier_points.foreach_set("co", flat)
# doesn't seem to work for handles so set them in loop
for bp in s.bezier_points:
bp.handle_left_type = bp.handle_right_type = 'AUTO'

# lazy way to add curve object