Skip to content

Commit c8601ae

Browse files
Copilotpontemonti
andauthored
Optimize file I/O by caching pyproject data during first pass (#81)
* Initial plan * Optimize file I/O by caching pyproject data during first pass Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
1 parent 709fb67 commit c8601ae

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

generate_dependency_diagram.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ def main():
156156
pkg_type = determine_package_type(member_path)
157157
package_configs.append((member_path, pkg_type))
158158

159-
# Collect all package names first
159+
# Collect all package names first and cache pyproject data
160160
all_package_names = set()
161161
packages: List[PackageInfo] = []
162+
pyproject_data_cache: Dict[str, Dict] = {}
162163

163164
for path_str, pkg_type in package_configs:
164165
pyproject_path = repo_root / path_str / 'pyproject.toml'
@@ -174,12 +175,15 @@ def main():
174175
pkg_name = pyproject_data['project']['name']
175176
all_package_names.add(pkg_name)
176177

178+
# Cache the pyproject data to avoid reading the file again
179+
pyproject_data_cache[pkg_name] = pyproject_data
180+
177181
pkg_info = PackageInfo(pkg_name, pkg_type, pyproject_path)
178182
packages.append(pkg_info)
179183

180-
# Extract dependencies for each package
184+
# Extract dependencies for each package using cached data
181185
for pkg in packages:
182-
pyproject_data = read_pyproject_toml(pkg.path)
186+
pyproject_data = pyproject_data_cache[pkg.name]
183187
pkg.dependencies = extract_dependencies(pyproject_data, all_package_names)
184188

185189
# Generate Mermaid diagram

0 commit comments

Comments
 (0)