code: def geom_length(geom):
      
      if geom.geom_type == 'Point':
          return 1
      if hasattr(geom, 'exterior'):
          geom = geom.exterior
      if not geom.geom_type.startswith('Multi') and hasattr(geom, 'array_interface_base'):
          return len(geom.array_interface_base['data'])//2
      else:
          length = 0
          for g in geom:
              length += geom_length(g)
          return length
docs: Calculates the length of coordinates in a shapely geometry.