Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(common): improve
Concrete
construction performance
- Loading branch information
Showing
6 changed files
with
207 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from ibis.common.annotations import attribute | ||
from ibis.common.collections import frozendict | ||
from ibis.common.grounds import Concrete | ||
|
||
pytestmark = pytest.mark.benchmark | ||
|
||
|
||
class MyObject(Concrete): | ||
a: int | ||
b: str | ||
c: tuple[int, ...] | ||
d: frozendict[str, int] | ||
|
||
@attribute.default | ||
def e(self): | ||
return self.a * 2 | ||
|
||
@attribute.default | ||
def f(self): | ||
return self.b * 2 | ||
|
||
@attribute.default | ||
def g(self): | ||
return self.c * 2 | ||
|
||
|
||
def test_concrete_construction(benchmark): | ||
benchmark(MyObject, 1, "2", c=(3, 4), d=frozendict(e=5, f=6)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters