code: def geom_dup(geom):
      
      g = ogr.CreateGeometryFromWkt(geom.ExportToWkt())
      g.AssignSpatialReference(geom.GetSpatialReference())
      return g
docs: Create duplicate geometry
      
      Needed to avoid segfault when passing geom around. See: http://trac.osgeo.org/gdal/wiki/PythonGotchas