Skip to content

Commit

Permalink
feat(wip): working on reuse overrides between deps
Browse files Browse the repository at this point in the history
  • Loading branch information
raceychan committed Feb 17, 2025
1 parent 2af5f99 commit 0b4af8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions ididi/graph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ from typing import (
Callable,
Container,
ContextManager,
Final,
Generator,
Generic,
Hashable,
Expand Down Expand Up @@ -93,8 +92,6 @@ AnyScope = Union["SyncScope", "AsyncScope"]
ScopeToken = Token[AnyScope]
ScopeContext = ContextVar[AnyScope]

_SCOPE_CONTEXT: Final[ScopeContext] = ContextVar("idid_scope_ctx")

class Resolver:
__slots__ = SharedSlots

Expand Down Expand Up @@ -371,6 +368,10 @@ class Resolver:
"""
...

def add_nodes(
self, *nodes: Union[IDependent[T], tuple[IDependent[T], INodeConfig]]
) -> None: ...

class ScopeMixin(Generic[Stack]):
__slots__ = ()

Expand Down
17 changes: 11 additions & 6 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@ def test_entry(dg: Graph, dependents: list[type]):

SERVICE_REGISTRY: set[UserService] = set()

class Conn:
...
class Conn: ...

class Repo:
...
class Repo: ...

class Cache:
...
class Cache: ...

@contextmanager
def get_conn() -> Resource[Conn]:
Expand Down Expand Up @@ -283,3 +280,11 @@ def create_user(
│ └─ 0.007 dict.get <built-in>
└─ 0.016 [self] tests/test_benchmark.py
"""

"""
1.4.5
menaul construction took 0.026685
ididi resolve took 0.027252
current implementation(without reuse) is 1.021248 times slower
"""

0 comments on commit 0b4af8a

Please sign in to comment.