Please, consider to use OSL for this task. I know is may sound strange because it is for shaders, not geometry - but shading part can be simply ignored for this case, or extended. And some features may be useful for getting geometry too - raycasts, queries, etc
It is already has many rendering/surface related concepts in place, documented, with examples, etc, etc
It is really fully-featured, c-like, compilable and well optimized (comparing to python) and already integrated with Nodes… and it is cool would like to see it in compositor nodes too, some days. For fast custom processing