Skip to content

Commit bc21dbc

Browse files
committed
Remove unused methods in BTree classes.
1 parent edd2b9b commit bc21dbc

File tree

1 file changed

+4
-55
lines changed

1 file changed

+4
-55
lines changed

pyperformance/data-files/benchmarks/bm_btree/run_benchmark.py

+4-55
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
object graph.
55
"""
66

7-
import collections.abc
87
import gc
98
import random
109
import sys
@@ -127,15 +126,6 @@ def get_count(self):
127126
result += node.get_count()
128127
return result
129128

130-
def get_node_count(self):
131-
"""() -> int
132-
How many nodes are here, including descendants?
133-
"""
134-
result = 1
135-
for node in self.nodes or []:
136-
result += node.get_node_count()
137-
return result
138-
139129
def get_level(self):
140130
"""() -> int
141131
How many levels of nodes are there between this node
@@ -236,23 +226,20 @@ def is_big(node):
236226
self.nodes = self.nodes[0].nodes
237227

238228

239-
class BTree(collections.abc.MutableMapping):
229+
class BTree:
240230
"""
241231
Instance attributes:
242232
root: BNode
243233
"""
244234

245235
__slots__ = ['root']
246236

247-
def __init__(self, node_constructor=BNode):
248-
assert issubclass(node_constructor, BNode)
249-
self.root = node_constructor()
237+
def __init__(self):
238+
self.root = BNode()
250239

251-
def __nonzero__(self):
240+
def __bool__(self):
252241
return bool(self.root.items)
253242

254-
__bool__ = __nonzero__
255-
256243
def iteritems(self):
257244
for item in self.root:
258245
yield item
@@ -261,39 +248,16 @@ def iterkeys(self):
261248
for item in self.root:
262249
yield item[0]
263250

264-
def itervalues(self):
265-
for item in self.root:
266-
yield item[1]
267-
268-
def items(self):
269-
return list(self.iteritems())
270-
271-
def keys(self):
272-
return list(self.iterkeys())
273-
274-
def values(self):
275-
return list(self.itervalues())
276-
277251
def __iter__(self):
278252
for key in self.iterkeys():
279253
yield key
280254

281255
def __contains__(self, key):
282256
return self.root.search(key) is not None
283257

284-
def has_key(self, key):
285-
return self.root.search(key) is not None
286-
287258
def __setitem__(self, key, value):
288259
self.add(key, value)
289260

290-
def setdefault(self, key, value):
291-
item = self.root.search(key)
292-
if item is None:
293-
self.add(key, value)
294-
return value
295-
return item[1]
296-
297261
def __getitem__(self, key):
298262
item = self.root.search(key)
299263
if item is None:
@@ -303,9 +267,6 @@ def __getitem__(self, key):
303267
def __delitem__(self, key):
304268
self.root.delete(key)
305269

306-
def clear(self):
307-
self.root = self.root.__class__()
308-
309270
def get(self, key, default=None):
310271
"""(key:anything, default:anything=None) -> anything"""
311272
try:
@@ -330,18 +291,6 @@ def __len__(self):
330291
Compute and return the total number of items."""
331292
return self.root.get_count()
332293

333-
def get_depth(self):
334-
"""() -> int
335-
How many levels of nodes are used for this BTree?
336-
"""
337-
return self.root.get_level() + 1
338-
339-
def get_node_count(self):
340-
"""() -> int
341-
How many nodes are used for this BTree?
342-
"""
343-
return self.root.get_node_count()
344-
345294

346295
class Record:
347296
def __init__(self, a, b, c, d, e, f):

0 commit comments

Comments
 (0)