code: def split(url):
      scheme = netloc = path = query = fragment = ''
      ip6_start = url.find('[')
      scheme_end = url.find(':')
      if ip6_start > 0 and ip6_start < scheme_end:
          scheme_end = -1
      if scheme_end > 0:
          for c in url[:scheme_end]:
              if c not in SCHEME_CHARS:
                  break
          else:
              scheme = url[:scheme_end].lower()
              rest = url[scheme_end:].lstrip(':/')
      if not scheme:
          rest = url
      l_path = rest.find('/')
      l_query = rest.find('?')
      l_frag = rest.find('
      if l_path > 0:
          if l_query > 0 and l_frag > 0:
              netloc = rest[:l_path]
              path = rest[l_path:min(l_query, l_frag)]
          elif l_query > 0:
              if l_query > l_path:
                  netloc = rest[:l_path]
                  path = rest[l_path:l_query]
              else:
                  netloc = rest[:l_query]
                  path = ''
          elif l_frag > 0:
              netloc = rest[:l_path]
              path = rest[l_path:l_frag]
          else:
              netloc = rest[:l_path]
              path = rest[l_path:]
      else:
          if l_query > 0:
              netloc = rest[:l_query]
          elif l_frag > 0:
              netloc = rest[:l_frag]
          else:
              netloc = rest
      if l_query > 0:
          if l_frag > 0:
              query = rest[l_query+1:l_frag]
          else:
              query = rest[l_query+1:]
      if l_frag > 0:
          fragment = rest[l_frag+1:]
      if not scheme:
          path = netloc + path
          netloc = ''
      return SplitResult(scheme, netloc, path, query, fragment)