Skip to content
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

Added '__slots__' in classes #29 #30

Merged
merged 2 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
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