Skip to content

Commit

Permalink
Added '__slots__' in classes #29 (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
udhayacommits authored and czgdp1807 committed Oct 24, 2019
1 parent e820aa1 commit fbc4a25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pydatastructs/linear_data_structures/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class OneDimensionalArray(Array):
.. [1] https://en.wikipedia.org/wiki/Array_data_structure#One-dimensional_arrays
'''

__slots__ = ['_size', '_data', '_dtype']

def __new__(cls, dtype=NoneType, *args, **kwargs):
if dtype == NoneType or len(args) not in (1, 2):
raise ValueError("1D array cannot be created due to incorrect"
Expand Down
2 changes: 2 additions & 0 deletions pydatastructs/miscellaneous_data_structures/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def peek(self):

class ArrayStack(Stack):

__slots__ = ['maxsize', 'top', 'items', 'dtype']

def __new__(cls, maxsize=None, top=0, items=None, dtype=int):
if not _check_type(maxsize, int):
raise ValueError("maxsize is missing.")
Expand Down
1 change: 1 addition & 0 deletions pydatastructs/trees/binary_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class BinarySearchTree(BinaryTree):
pydatastructs.trees.binary_tree.BinaryTree
"""

def insert(self, key, data):
walk = self.root_idx
if self.tree[walk].key == None:
Expand Down

0 comments on commit fbc4a25

Please sign in to comment.