def signed_varint(i):
 if (i >= 0):
  return varint((i << 1))
 return varint(((i << 1) ^ (~ 0)))

def signed_varint ( i ) : if ( i >= 0 ) : return varint ( ( i << 1 ) ) return varint ( ( ( i << 1 ) ^ ( ~ 0 ) ) )
zig-zag encodes a signed integer into a varint .