You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
codeanalyzer-python 1.6.0 makes level-4 analysis of large projects use about 7x less memory, with the same output. It also raises the minimum Python version to 3.11.
鈿狅笍 Breaking changes
Python 3.11 or newer is now required. Python 3.9 and 3.10 are no longer supported (requires-python = ">=3.11"). The new memory-saving records need pydantic v2, and below 3.11 the dependency pins installed pydantic v1. Migration: install canpy under Python 3.11+. The tomli backport and the pydantic-v1 code paths are gone. codeanalyzer.schema.PYDANTIC_V2 still imports, and is always True.
The schema's leaf record types are now dataclasses, not pydantic models. This affects in-process users only: Span, BodyNode, the cfg/cdg/ddg/summary/param_* edges, PyCallEdge, PyCallsite, PyCallArgument, PySymbol, PyComment, PyVariableDeclaration, PyCallableParameter, PyDecorator and PyImport no longer have .model_dump() or .model_validate(). Migration: use dataclasses.asdict(...) or the constructor. The container models (PyModule, PyClass, PyCallable, PyApplication, Analysis) and the codeanalyzer.schema helpers handle them transparently. The analysis.json format and the schema version are unchanged.
Highlights
About 7x less memory at level 4 (Cut level-4 memory ~7x: slotted leaf records, streamed JSON/cache/cypher, early release of intermediates聽#224). On a 6,685-module project (Odoo 20.0), peak memory fell from 42.6 GB to 5.7 GB for JSON output, and from 65.1 GB to 5.5 GB for --emit neo4j. That project now fits on a 16 GB laptop. On the same input, analysis.json and the analysis cache have the same content as 1.5.4. The Neo4j snapshot has the same statements, though edge batches can come in a different order.
Streamed output.analysis.json, the cache and graph.cypher are written piece by piece, not built as whole-tree copies in memory. analysis.json now uses compact JSON separators, so the whitespace differs but the content is the same.
Ray memory controls. The symbol-table phase runs on a private Ray cluster with object spilling turned off, and the cluster shuts down when the phase finishes. Two new environment variables control it: CANPY_RAY_OBJECT_STORE caps the object store (in bytes, default 1 GB), and CANPY_RAY_CPUS caps the number of workers.
Thanks to @saurabhjha1 for the memory work, their first contribution!
Upgrade
pip install -U "codeanalyzer-python==1.6.0"
For the optional live Neo4j push: pip install -U "codeanalyzer-python[neo4j]==1.6.0"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
codeanalyzer-python 1.6.0 makes level-4 analysis of large projects use about 7x less memory, with the same output. It also raises the minimum Python version to 3.11.
requires-python = ">=3.11"). The new memory-saving records need pydantic v2, and below 3.11 the dependency pins installed pydantic v1.Migration: install
canpyunder Python 3.11+. Thetomlibackport and the pydantic-v1 code paths are gone.codeanalyzer.schema.PYDANTIC_V2still imports, and is alwaysTrue.Span,BodyNode, thecfg/cdg/ddg/summary/param_*edges,PyCallEdge,PyCallsite,PyCallArgument,PySymbol,PyComment,PyVariableDeclaration,PyCallableParameter,PyDecoratorandPyImportno longer have.model_dump()or.model_validate().Migration: use
dataclasses.asdict(...)or the constructor. The container models (PyModule,PyClass,PyCallable,PyApplication,Analysis) and thecodeanalyzer.schemahelpers handle them transparently. Theanalysis.jsonformat and the schema version are unchanged.Highlights
--emit neo4j. That project now fits on a 16 GB laptop. On the same input,analysis.jsonand the analysis cache have the same content as 1.5.4. The Neo4j snapshot has the same statements, though edge batches can come in a different order.analysis.json, the cache andgraph.cypherare written piece by piece, not built as whole-tree copies in memory.analysis.jsonnow uses compact JSON separators, so the whitespace differs but the content is the same.CANPY_RAY_OBJECT_STOREcaps the object store (in bytes, default 1 GB), andCANPY_RAY_CPUScaps the number of workers.Thanks to @saurabhjha1 for the memory work, their first contribution!
Upgrade
pip install -U "codeanalyzer-python==1.6.0"For the optional live Neo4j push:
pip install -U "codeanalyzer-python[neo4j]==1.6.0"Links: GitHub release 路 CHANGELOG
All reactions