8000 Add the 'btree' benchmark. by nascheme · Pull Request #381 · python/pyperformance · GitHub
[go: up one dir, main page]

Skip to content

Add the 'btree' benchmark. #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use 'yield from' in some places.
  • Loading branch information
nascheme committed Jan 30, 2025
commit 52ac69d0a23894240ea2a7da8620df27c96c4317
15 changes: 5 additions & 10 deletions pyperformance/data-files/benchmarks/bm_btree/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ def is_leaf(self):

def __iter__(self):
if self.is_leaf():
for item in self.items:
yield item
yield from self.items
else:
for position, item in enumerate(self.items):
for it in self.nodes[position]:
yield it
yield from self.nodes[position]
yield item
for it in self.nodes[-1]:
yield it
yield from self.nodes[-1]

def is_full(self):
return len(self.items) == 2 * self.minimum_degree - 1
Expand Down Expand Up @@ -241,16 +238,14 @@ def __bool__(self):
return bool(self.root.items)

def iteritems(self):
for item in self.root:
yield item
yield from self.root

def iterkeys(self):
for item in self.root:
yield item[0]

def __iter__(self):
for key in self.iterkeys():
yield key
yield from self.iterkeys()

def __contains__(self, key):
return self.root.search(key) is not None
Expand Down
Loading
0