parameters: (dir, maxlevels=10, ddir=None, force=False, rx=None,
                  quiet=0, legacy=False, optimize=-1, workers=1,
                  invalidation_mode=None)
return_statement: return success
docstring: Byte-compile all modules in the given directory tree.
  
      Arguments (only dir is required):
  
      dir:       the directory to byte-compile
      maxlevels: maximum recursion level (default 10)
      ddir:      the directory that will be prepended to the path to the
                 file as it is compiled into each byte-code file.
      force:     if True, force compilation, even if timestamps are up-to-date
      quiet:     full output with False or 0, errors only with 1,
                 no output with 2
      legacy:    if True, produce legacy pyc paths instead of PEP 3147 paths
      optimize:  optimization level or -1 for level of the interpreter
      workers:   maximum number of parallel workers
      invalidation_mode: how the up-to-dateness of the pyc will be checked
docstring_summary: Byte-compile all modules in the given directory tree.
docstring_tokens: Byte - compile all modules in the given directory tree .
function: def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
                  quiet=0, legacy=False, optimize=-1, workers=1,
                  invalidation_mode=None):
      """Byte-compile all modules in the given directory tree.
  
      Arguments (only dir is required):
  
      dir:       the directory to byte-compile
      maxlevels: maximum recursion level (default 10)
      ddir:      the directory that will be prepended to the path to the
                 file as it is compiled into each byte-code file.
      force:     if True, force compilation, even if timestamps are up-to-date
      quiet:     full output with False or 0, errors only with 1,
                 no output with 2
      legacy:    if True, produce legacy pyc paths instead of PEP 3147 paths
      optimize:  optimization level or -1 for level of the interpreter
      workers:   maximum number of parallel workers
      invalidation_mode: how the up-to-dateness of the pyc will be checked
      """
      ProcessPoolExecutor = None
      if workers is not None:
          if workers < 0:
              raise ValueError('workers must be greater or equal to 0')
          elif workers != 1:
              try:
                  # Only import when needed, as low resource platforms may
                  # fail to import it
                  from concurrent.futures import ProcessPoolExecutor
              except ImportError:
                  workers = 1
      files_and_ddirs = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
                                  ddir=ddir)
      success = True
      if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
          workers = workers or None
          with ProcessPoolExecutor(max_workers=workers) as executor:
              results = executor.map(
                      partial(_compile_file_tuple,
                              force=force, rx=rx, quiet=quiet,
                              legacy=legacy, optimize=optimize,
                              invalidation_mode=invalidation_mode,
                          ),
                      files_and_ddirs)
              success = min(results, default=True)
      else:
          for file, dfile in files_and_ddirs:
              if not compile_file(file, dfile, force, rx, quiet,
                                  legacy, optimize, invalidation_mode):
                  success = False
      return success
function_tokens: def compile_dir ( dir , maxlevels = 10 , ddir = None , force = False , rx = None , quiet = 0 , legacy = False , optimize = - 1 , workers = 1 , invalidation_mode = None ) : ProcessPoolExecutor = None if workers is not None : if workers < 0 : raise ValueError ( 'workers must be greater or equal to 0' ) elif workers != 1 : try : # Only import when needed, as low resource platforms may # fail to import it from concurrent . futures import ProcessPoolExecutor except ImportError : workers = 1 files_and_ddirs = _walk_dir ( dir , quiet = quiet , maxlevels = maxlevels , ddir = ddir ) success = True if workers is not None and workers != 1 and ProcessPoolExecutor is not None : workers = workers or None with ProcessPoolExecutor ( max_workers = workers ) as executor : results = executor . map ( partial ( _compile_file_tuple , force = force , rx = rx , quiet = quiet , legacy = legacy , optimize = optimize , invalidation_mode = invalidation_mode , ) , files_and_ddirs ) success = min ( results , default = True ) else : for file , dfile in files_and_ddirs : if not compile_file ( file , dfile , force , rx , quiet , legacy , optimize , invalidation_mode ) : success = False return success