def create_size_estimators():
  """Create a dict of name to a function that returns an estimated size for a given target.

  The estimated size is used to build the largest targets first (subject to dependency constraints).
  Choose 'random' to choose random sizes for each target, which may be useful for distributed
  builds.
  :returns: Dict of a name to a function that returns an estimated size.
  """
  def line_count(filename):
    with open(filename, 'rb') as fh:
      return sum(1 for line in fh)
  return {
    'linecount': lambda srcs: sum(line_count(src) for src in srcs),
    'filecount': lambda srcs: len(srcs),
    'filesize': lambda srcs: sum(os.path.getsize(src) for src in srcs),
    'nosize': lambda srcs: 0,
    'random': lambda srcs: random.randint(0, 10000),
  }
Create a dict of name to a function that returns an estimated size for a given target.

  The estimated size is used to build the largest targets first (subject to dependency constraints).
  Choose 'random' to choose random sizes for each target, which may be useful for distributed
  builds.
  :returns: Dict of a name to a function that returns an estimated size.