⚡️ Speed up function construct_uv_flags by 303%
#589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📄 303% (3.03x) speedup for
construct_uv_flagsinmarimo/_cli/sandbox.py⏱️ Runtime :
7.07 milliseconds→1.76 milliseconds(best of250runs)📝 Explanation and details
The optimized code achieves a 302% speedup through several key performance optimizations:
Primary Optimization: Reduced
is_marimo_dependencyCallsThe biggest performance gain comes from eliminating redundant calls to
is_marimo_dependency(). The original code called this function 3 times per dependency:The optimized version uses a single loop that categorizes dependencies in one pass, reducing function calls from 3N to N (where N is the number of dependencies).
Caching Expensive Operations
is_editable("marimo")caching: This expensive metadata lookup is cached globally since it's always called with "marimo" and the result doesn't change during executionget_marimo_dir()caching: Only computed when needed and cached for subsequent callsMicro-optimizations
next((d for d in marimo_deps if "[" in d), None)with a simple loop to avoid generator overheadpyproject.namein_resolve_requirements_txt_lineslen(additional_deps) > 0toif additional_deps:for better performanceextendcalls for index configs into a single operationPerformance Impact by Test Case
The optimization shows excellent scalability:
The most dramatic improvements occur in typical usage scenarios with fewer dependencies, where the overhead of redundant
is_marimo_dependencycalls dominated execution time. For sandbox environments that are frequently created/destroyed, this optimization significantly reduces startup latency.✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
from pathlib import Path
imports
import pytest
from marimo._cli.sandbox import construct_uv_flags
--- Minimal mocks for dependencies ---
class DummyTempFile:
"""Mock of tempfile._TemporaryFileWrapper[str] for testing."""
def init(self):
self.contents = ""
self.name = "dummy_requirements.txt"
def write(self, s: str):
self.contents = s
class DummyPyProjectReader:
"""Mock of PyProjectReader for testing."""
def init(
self,
name=None,
requirements_txt_lines=None,
python_version=None,
index_url=None,
extra_index_urls=None,
index_configs=None
):
self.name = name
self.requirements_txt_lines = requirements_txt_lines or []
self.python_version = python_version
self.index_url = index_url
self.extra_index_urls = extra_index_urls or []
self.index_configs = index_configs or []
--- Minimal stub for version ---
version = "1.2.3"
from marimo._cli.sandbox import construct_uv_flags
--- Unit tests ---
-----------------------
1. Basic Test Cases
-----------------------
def test_basic_no_dependencies():
# No requirements, should add marimo==version and --refresh
pyproject = DummyPyProjectReader(requirements_txt_lines=[])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 119μs -> 4.26μs (2696% faster)
def test_basic_with_dependencies():
# requirements include numpy, should add marimo==version and not --refresh
pyproject = DummyPyProjectReader(requirements_txt_lines=["numpy"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 114μs -> 5.35μs (2034% faster)
def test_basic_with_marimo_dependency_versioned():
# requirements include marimo==1.0.0, should keep version
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo==1.0.0", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 116μs -> 6.50μs (1687% faster)
def test_basic_with_marimo_dependency_unversioned():
# requirements include marimo, should add version
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 113μs -> 5.94μs (1819% faster)
def test_basic_with_additional_deps():
# Additional deps should be added to --with
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], ["pytest", "requests"]); flags = codeflash_output # 113μs -> 5.34μs (2019% faster)
idx = flags.index("--with")
def test_basic_with_additional_features():
# Additional features should be bracketed in marimo dep
pyproject = DummyPyProjectReader(requirements_txt_lines=[])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp", "recommended"], []); flags = codeflash_output # 111μs -> 3.56μs (3022% faster)
-----------------------
2. Edge Test Cases
-----------------------
def test_edge_bracketed_marimo_dependency():
# requirements include marimo[foo], should add version and features
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[foo]", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], []); flags = codeflash_output # 115μs -> 6.37μs (1708% faster)
def test_edge_multiple_marimo_dependencies():
# requirements include marimo, marimo[foo], should prefer bracketed
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo", "marimo[foo]", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], []); flags = codeflash_output # 115μs -> 6.67μs (1633% faster)
def test_edge_marimo_dependency_with_version_and_bracket():
# requirements include marimo[foo]==1.0.0, should keep version
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[foo]==1.0.0", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], []); flags = codeflash_output # 114μs -> 6.23μs (1733% faster)
def test_edge_with_python_version():
# Should add --python flag
pyproject = DummyPyProjectReader(requirements_txt_lines=[], python_version="3.11")
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 141μs -> 4.95μs (2753% faster)
idx = flags.index("--python")
def test_edge_with_index_url():
# Should add --index-url flag
pyproject = DummyPyProjectReader(requirements_txt_lines=[], index_url="https://pypi.org/simple")
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 118μs -> 3.87μs (2957% faster)
idx = flags.index("--index-url")
def test_edge_with_extra_index_urls():
# Should add --extra-index-url for each url
pyproject = DummyPyProjectReader(requirements_txt_lines=[], extra_index_urls=["https://extra1", "https://extra2"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 114μs -> 7.13μs (1505% faster)
def test_edge_with_index_configs():
# Should add --index for each config with url
pyproject = DummyPyProjectReader(requirements_txt_lines=[], index_configs=[{"url": "https://custom1"}, {"url": "https://custom2"}])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 113μs -> 4.32μs (2526% faster)
def test_edge_marimo_dependency_with_weird_format():
# requirements include marimo[foo]==1.0.0, marimo[bar], should prefer bracketed and versioned
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[foo]==1.0.0", "marimo[bar]", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], []); flags = codeflash_output # 118μs -> 7.74μs (1436% faster)
def test_edge_marimo_dependency_with_special_chars():
# requirements include marimo>=1.0.0, should keep version specifier
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo>=1.0.0", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 116μs -> 6.15μs (1791% faster)
def test_edge_non_marimo_dependency_with_brackets():
# requirements include marimo-foo, should not be treated as marimo
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo-foo", "pandas"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 115μs -> 5.82μs (1893% faster)
-----------------------
3. Large Scale Test Cases
-----------------------
def test_large_scale_many_dependencies():
# 500 dependencies, should handle efficiently
deps = [f"package{i}" for i in range(500)]
pyproject = DummyPyProjectReader(requirements_txt_lines=deps)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 322μs -> 218μs (48.0% faster)
for dep in deps:
pass
def test_large_scale_many_additional_deps():
# 500 additional deps, should join all in --with
pyproject = DummyPyProjectReader(requirements_txt_lines=[])
temp_file = DummyTempFile()
additional_deps = [f"extra{i}" for i in range(500)]
codeflash_output = construct_uv_flags(pyproject, temp_file, [], additional_deps); flags = codeflash_output # 116μs -> 8.08μs (1346% faster)
idx = flags.index("--with")
joined = flags[idx+1]
for dep in additional_deps:
pass
def test_large_scale_many_extra_index_urls():
# 500 extra index urls, should add all
urls = [f"https://extra{i}.com" for i in range(500)]
pyproject = DummyPyProjectReader(requirements_txt_lines=[], extra_index_urls=urls)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 133μs -> 41.5μs (223% faster)
for url in urls:
pass
def test_large_scale_many_index_configs():
# 500 index configs, should add all
configs = [{"url": f"https://custom{i}.com"} for i in range(500)]
pyproject = DummyPyProjectReader(requirements_txt_lines=[], index_configs=configs)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 150μs -> 33.3μs (351% faster)
for config in configs:
pass
def test_large_scale_all_options():
# 100 dependencies, 100 additional_deps, 100 extra_index_urls, 100 index_configs
deps = [f"package{i}" for i in range(100)]
additional_deps = [f"extra{i}" for i in range(100)]
extra_index_urls = [f"https://extra{i}.com" for i in range(100)]
index_configs = [{"url": f"https://custom{i}.com"} for i in range(100)]
pyproject = DummyPyProjectReader(
requirements_txt_lines=deps,
python_version="3.10",
index_url="https://pypi.org/simple",
extra_index_urls=extra_index_urls,
index_configs=index_configs
)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], additional_deps); flags = codeflash_output # 173μs -> 66.9μs (160% faster)
# Check all dependencies written
for dep in deps:
pass
# Check all additional_deps in --with
idx = flags.index("--with")
joined = flags[idx+1]
for dep in additional_deps:
pass
for url in extra_index_urls:
pass
for config in index_configs:
pass
codeflash_output is used to check that the output of the original code is the same as that of the optimized code.
#------------------------------------------------
from pathlib import Path
imports
import pytest
from marimo._cli.sandbox import construct_uv_flags
--- Minimal stubs and helpers to support unit testing ---
class DummyTempFile:
"""Stub for tempfile._TemporaryFileWrapper[str]"""
def init(self):
self.contents = ""
self.name = "dummy_temp_file.txt"
def write(self, s):
self.contents += s
class DummyPyProjectReader:
"""Stub for PyProjectReader, with all relevant attributes."""
def init(
self,
name=None,
requirements_txt_lines=None,
python_version=None,
index_url=None,
extra_index_urls=None,
index_configs=None
):
self.name = name
self.requirements_txt_lines = requirements_txt_lines or []
self.python_version = python_version
self.index_url = index_url
self.extra_index_urls = extra_index_urls or []
self.index_configs = index_configs or []
version = "1.2.3"
from marimo._cli.sandbox import construct_uv_flags
--- Unit tests ---
1. Basic Test Cases
def test_no_dependencies_adds_marimo_and_refresh():
# No dependencies: should add marimo==version and --refresh
pyproject = DummyPyProjectReader(requirements_txt_lines=[])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 114μs -> 3.99μs (2760% faster)
def test_marimo_dependency_with_no_version():
# Dependency "marimo" should be normalized to marimo==version
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 116μs -> 5.17μs (2146% faster)
def test_marimo_dependency_with_version():
# Dependency "marimo==0.9.0" should not be changed
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo==0.9.0"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 114μs -> 5.29μs (2069% faster)
def test_marimo_dependency_with_brackets_and_features():
# Dependency "marimo[lsp]" should add version and features
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[lsp]"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["recommended"], []); flags = codeflash_output # 115μs -> 5.40μs (2047% faster)
def test_additional_deps_are_in_flags():
# Additional deps should be joined and added with --with
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], ["numpy", "pandas"]); flags = codeflash_output # 113μs -> 5.58μs (1938% faster)
idx = flags.index("--with")
def test_python_version_and_index_url():
# Should add --python and --index-url flags
pyproject = DummyPyProjectReader(
requirements_txt_lines=["requests"],
python_version="3.11",
index_url="https://pypi.org/simple"
)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 113μs -> 5.52μs (1952% faster)
def test_extra_index_urls_and_index_configs():
# Should add --extra-index-url and --index flags
pyproject = DummyPyProjectReader(
requirements_txt_lines=["requests"],
extra_index_urls=["https://extra1.org/simple", "https://extra2.org/simple"],
index_configs=[{"url": "https://config-index.org/simple"}]
)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 113μs -> 9.08μs (1152% faster)
def test_multiple_marimo_dependencies_prefers_bracketed():
# If both "marimo" and "marimo[lsp]" are present, bracketed is preferred
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo", "marimo[lsp]"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["recommended"], []); flags = codeflash_output # 118μs -> 6.16μs (1816% faster)
def test_non_marimo_dependency_passes_through():
# Non-marimo deps should pass through unchanged
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests>=2.0.0"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 114μs -> 5.24μs (2082% faster)
2. Edge Test Cases
def test_empty_requirements_and_additional_features():
# No deps, but additional features for marimo
pyproject = DummyPyProjectReader(requirements_txt_lines=[])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp", "recommended"], []); flags = codeflash_output # 111μs -> 3.51μs (3071% faster)
def test_requirements_with_only_marimo_bracketed_and_features():
# Only marimo[recommended], should add version and any new features
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[recommended]"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], []); flags = codeflash_output # 114μs -> 5.73μs (1905% faster)
def test_index_configs_without_url_are_skipped():
# Index configs without "url" key should be skipped
pyproject = DummyPyProjectReader(
requirements_txt_lines=["requests"],
index_configs=[{"not_url": "foo"}, {"url": "https://index.org/simple"}]
)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 115μs -> 5.85μs (1868% faster)
def test_requirements_with_multiple_non_marimo_deps():
# Multiple non-marimo dependencies
deps = ["requests", "numpy", "pandas"]
pyproject = DummyPyProjectReader(requirements_txt_lines=deps)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 116μs -> 6.43μs (1705% faster)
for dep in deps:
pass
def test_requirements_with_marimo_and_non_marimo():
# Mix of marimo and other deps
deps = ["marimo", "requests"]
pyproject = DummyPyProjectReader(requirements_txt_lines=deps)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 116μs -> 5.86μs (1896% faster)
def test_requirements_with_marimo_and_version_and_features():
# marimo==0.9.0 and features, should not add version or features
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo==0.9.0"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], []); flags = codeflash_output # 113μs -> 5.12μs (2123% faster)
def test_requirements_with_marimo_bracketed_and_version():
# marimo[lsp]==0.9.0, should not add features or change version
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[lsp]==0.9.0"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["recommended"], []); flags = codeflash_output # 115μs -> 5.46μs (2008% faster)
def test_requirements_with_marimo_bracketed_and_no_version():
# marimo[lsp], should add version and additional features
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo[lsp]"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["recommended"], []); flags = codeflash_output # 114μs -> 5.24μs (2084% faster)
def test_requirements_with_marimo_and_bracketed_and_non_marimo():
# marimo, marimo[lsp], requests: bracketed is preferred
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo", "marimo[lsp]", "requests"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["recommended"], []); flags = codeflash_output # 119μs -> 6.74μs (1675% faster)
def test_requirements_with_marimo_and_bracketed_and_version():
# marimo, marimo[lsp]==0.9.0: bracketed with version is preferred
pyproject = DummyPyProjectReader(requirements_txt_lines=["marimo", "marimo[lsp]==0.9.0"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["recommended"], []); flags = codeflash_output # 121μs -> 6.08μs (1891% faster)
def test_requirements_with_non_marimo_and_additional_features():
# No marimo dep, but additional features: should add marimo with features and version
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp", "recommended"], []); flags = codeflash_output # 115μs -> 5.07μs (2178% faster)
def test_requirements_with_non_marimo_and_additional_deps():
# Non-marimo dep and additional_deps
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], ["pytest"]); flags = codeflash_output # 113μs -> 5.38μs (2019% faster)
def test_requirements_with_empty_extra_index_urls():
# Empty extra_index_urls should not add any --extra-index-url flags
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"], extra_index_urls=[])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 114μs -> 4.88μs (2242% faster)
def test_requirements_with_empty_index_configs():
# Empty index_configs should not add any --index flags
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"], index_configs=[])
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 113μs -> 5.02μs (2154% faster)
3. Large Scale Test Cases
def test_large_number_of_dependencies():
# Test with 1000 dependencies
deps = [f"package{i}" for i in range(1000)]
pyproject = DummyPyProjectReader(requirements_txt_lines=deps)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 528μs -> 431μs (22.7% faster)
# All dependencies should be present
for dep in deps:
pass
def test_large_number_of_additional_deps():
# Test with 1000 additional_deps
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"])
temp_file = DummyTempFile()
additional_deps = [f"extra{i}" for i in range(1000)]
codeflash_output = construct_uv_flags(pyproject, temp_file, [], additional_deps); flags = codeflash_output # 126μs -> 13.2μs (861% faster)
# All additional deps should be joined with commas
joined = flags[flags.index("--with")+1]
for dep in additional_deps:
pass
def test_large_number_of_extra_index_urls():
# Test with 1000 extra_index_urls
extra_index_urls = [f"https://extra{i}.org/simple" for i in range(1000)]
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"], extra_index_urls=extra_index_urls)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 157μs -> 74.6μs (111% faster)
# All extra_index_urls should be present in flags
for url in extra_index_urls:
pass
def test_large_number_of_index_configs():
# Test with 1000 index_configs
index_configs = [{"url": f"https://index{i}.org/simple"} for i in range(1000)]
pyproject = DummyPyProjectReader(requirements_txt_lines=["requests"], index_configs=index_configs)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, [], []); flags = codeflash_output # 186μs -> 61.6μs (202% faster)
for config in index_configs:
pass
def test_large_number_of_all_options():
# Test with 1000 deps, 1000 additional_deps, 1000 extra_index_urls, 1000 index_configs
deps = [f"package{i}" for i in range(1000)]
additional_deps = [f"extra{i}" for i in range(1000)]
extra_index_urls = [f"https://extra{i}.org/simple" for i in range(1000)]
index_configs = [{"url": f"https://index{i}.org/simple"} for i in range(1000)]
pyproject = DummyPyProjectReader(
requirements_txt_lines=deps,
extra_index_urls=extra_index_urls,
index_configs=index_configs,
python_version="3.10",
index_url="https://pypi.org/simple"
)
temp_file = DummyTempFile()
codeflash_output = construct_uv_flags(pyproject, temp_file, ["lsp"], additional_deps); flags = codeflash_output # 649μs -> 589μs (10.2% faster)
# All deps present
for dep in deps:
pass
# All additional_deps present in --with
joined = flags[flags.index("--with")+1]
for dep in additional_deps:
pass
# All extra_index_urls present
for url in extra_index_urls:
pass
# All index_configs present
for config in index_configs:
pass
codeflash_output is used to check that the output of the original code is the same as that of the optimized code.
To edit these changes
git checkout codeflash/optimize-construct_uv_flags-mhu8fbqiand push.