code: def compilePoints(points):
      # If the set consists of all points in the glyph, it gets encoded with
      # a special encoding: a single zero byte.
      #
      # To use this optimization, points passed in must be empty set.
      # The following two lines are not strictly necessary as the main code
      # below would emit the same. But this is most common and faster.
      if not points:
          return b"\0"
  
      # In the 'gvar' table, the packing of point numbers is a little surprising.
      # It consists of multiple runs, each being a delta-encoded list of integers.
      # For example, the point set {17, 18, 19, 20, 21, 22, 23} gets encoded as
      # [6, 17, 1, 1, 1, 1, 1, 1]. The first value (6) is the run length minus 1.
      # There are two types of runs, with values being either 8 or 16 bit unsigned
      # integers.
      points = list(points)
      points.sort()
      numPoints = len(points)
  
      result = bytearray()
      # The binary representation starts with the total number of points in the set,
      # encoded into one or two bytes depending on the value.
      if numPoints < 0x80:
          result.append(numPoints)
      else:
          result.append((numPoints >> 8) | 0x80)
          result.append(numPoints & 0xFF)
  
      MAX_RUN_LENGTH = 127
      pos = 0
      lastValue = 0
      while pos < numPoints:
          runLength = 0
  
          headerPos = len(result)
          result.append(0)
  
          useByteEncoding = None
          while pos < numPoints and runLength <= MAX_RUN_LENGTH:
              curValue = points[pos]
              delta = curValue - lastValue
              if useByteEncoding is None:
                  useByteEncoding = 0 <= delta <= 0xFF
              if useByteEncoding and (delta > 0xFF or delta < 0):
                  # we need to start a new run (which will not use byte encoding)
                  break
              # TODO This never switches back to a byte-encoding from a short-encoding.
              # That's suboptimal.
              if useByteEncoding:
                  result.append(delta)
              else:
                  result.append(delta >> 8)
                  result.append(delta & 0xFF)
              lastValue = curValue
              pos += 1
              runLength += 1
          if useByteEncoding:
              result[headerPos] = runLength - 1
          else:
              result[headerPos] = (runLength - 1) | POINTS_ARE_WORDS
  
      return result
  
imports: from fontTools.misc.fixedTools import fixedToFloat, floatToFixed, floatToFixedToStr, strToFixedToFloat, otRound
  from fontTools.misc.textTools import safeEval
  import array
  from collections import Counter, defaultdict
  import io
  import logging
  import struct
  import sys
label_desc: Use image node_id 12 for calling the TupleVariation obj's underlying member method code with example usage: obj.compilePoints(points) and returns: result, bytes