Exemplo n.º 1
0
def optimize(output_filename):
    Graphs.startGraph()

    # First pass.
    if _progress:
        info("PASS 1:")

    makeOptimizationPass(initial_pass=True)
    Variables.complete = True

    finished = makeOptimizationPass(initial_pass=False)

    if Options.isExperimental("check_xml_persistence"):
        _checkXMLPersistence()

    # Demote compiled modules to bytecode, now that imports had a chance to be resolved, and
    # dependencies were handled.
    for module in ModuleRegistry.getDoneUserModules():
        if module.isCompiledPythonModule() and module.mode == "bytecode":
            demoteCompiledModuleToBytecode(module)

    if _progress:
        info("PASS 2 ... :")

    # Second, "endless" pass.
    while not finished:
        finished = makeOptimizationPass(initial_pass=False)

    Graphs.endGraph(output_filename)
Exemplo n.º 2
0
def optimize(output_filename):
    Graphs.startGraph()

    # First pass.
    if _progress:
        info("PASS 1:")

    makeOptimizationPass(initial_pass=True)
    Variables.complete = True

    finished = makeOptimizationPass(initial_pass=False)

    if Options.isExperimental("check_xml_persistence"):
        _checkXMLPersistence()

    # Demote compiled modules to bytecode, now that imports had a chance to be resolved, and
    # dependencies were handled.
    for module in ModuleRegistry.getDoneUserModules():
        if module.isCompiledPythonModule() and module.mode == "bytecode":
            demoteCompiledModuleToBytecode(module)

    if _progress:
        info("PASS 2 ... :")

    # Second, "endless" pass.
    while not finished:
        finished = makeOptimizationPass(initial_pass=False)

    Graphs.endGraph(output_filename)
Exemplo n.º 3
0
def optimize():
    Graphs.startGraph()

    # First pass.
    if _progress:
        info("PASS 1:")

    makeOptimizationPass(False)
    VariableRegistry.considerCompletion()
    finished = makeOptimizationPass(False)

    # Demote to bytecode if now.
    for module in ModuleRegistry.getDoneUserModules():
        if module.isPythonShlibModule():
            continue

        if module.mode == "bytecode":
            demoteCompiledModuleToBytecode(module)

    # Second, endless pass.
    if _progress:
        info("PASS 2..:")

    while not finished:
        finished = makeOptimizationPass(True)

    Graphs.endGraph()
Exemplo n.º 4
0
def optimize():
    Graphs.startGraph()

    # First pass.
    if _progress:
        info("PASS 1:")

    makeOptimizationPass(False)
    Variables.complete = True

    finished = makeOptimizationPass(False)

    if Options.isExperimental():
        new_roots = ModuleRegistry.root_modules.__class__()  # @UndefinedVariable

        for module in tuple(ModuleRegistry.getDoneModules()):
            ModuleRegistry.root_modules.remove(module)

            if module.isPythonShlibModule():
                continue

            text = module.asXmlText()
            open("out.xml", 'w').write(text)
            restored = restoreFromXML(text)
            retext = restored.asXmlText()
            open("out2.xml", 'w').write(retext)

            assert module.getOutputFilename() == restored.getOutputFilename(), \
               (module.getOutputFilename(),restored.getOutputFilename())

            # The variable versions give diffs.
            if False: # To manually enable, pylint: disable=W0125
                import difflib
                diff = difflib.unified_diff(
                    text.splitlines(),
                    retext.splitlines(),
                    "xml orig",
                    "xml reloaded"
                )
                for line in diff:
                    printLine(line)

            new_roots.add(restored)

        ModuleRegistry.root_modules = new_roots
        ModuleRegistry.startTraversal()

    # Demote to bytecode, now that imports had a chance to be resolved, and
    # dependencies were handled.
    for module in ModuleRegistry.getDoneUserModules():
        if module.isPythonShlibModule():
            continue

        if module.mode == "bytecode":
            demoteCompiledModuleToBytecode(module)

    if _progress:
        info("PASS 2 ... :")

    # Second, "endless" pass.
    while not finished:
        finished = makeOptimizationPass(True)

    Graphs.endGraph()
Exemplo n.º 5
0
def optimize():
    Graphs.startGraph()

    # First pass.
    if _progress:
        info("PASS 1:")

    makeOptimizationPass(False)
    Variables.complete = True

    finished = makeOptimizationPass(False)

    if Options.isExperimental():
        new_roots = ModuleRegistry.root_modules.__class__(
        )  # @UndefinedVariable

        for module in tuple(ModuleRegistry.getDoneModules()):
            ModuleRegistry.root_modules.remove(module)

            if module.isPythonShlibModule():
                continue

            text = module.asXmlText()
            open("out.xml", 'w').write(text)
            restored = restoreFromXML(text)
            retext = restored.asXmlText()
            open("out2.xml", 'w').write(retext)

            assert module.getOutputFilename() == restored.getOutputFilename(), \
               (module.getOutputFilename(),restored.getOutputFilename())

            # The variable versions give diffs.
            if False:  # To manually enable, pylint: disable=W0125
                import difflib
                diff = difflib.unified_diff(text.splitlines(),
                                            retext.splitlines(), "xml orig",
                                            "xml reloaded")
                for line in diff:
                    printLine(line)

            new_roots.add(restored)

        ModuleRegistry.root_modules = new_roots
        ModuleRegistry.startTraversal()

    # Demote to bytecode, now that imports had a chance to be resolved, and
    # dependencies were handled.
    for module in ModuleRegistry.getDoneUserModules():
        if module.isPythonShlibModule():
            continue

        if module.mode == "bytecode":
            demoteCompiledModuleToBytecode(module)

    if _progress:
        info("PASS 2 ... :")

    # Second, "endless" pass.
    while not finished:
        finished = makeOptimizationPass(True)

    Graphs.endGraph()