OmkarPathak/pygorithm

[enhancement] Removal/Rework of get_code(), time_complexities(), and modules.py

IanDoarn opened this issue · 1 comments

  • I've noticed that every directory/package has a modules.py file, is this truly necessary now that the documentation and README both state using help() to view the modules? I feel these can be outright removed, and the supported algorithms for each section can be simply listed on the README or we can point the user to the Documentation

  • I've also noticed that every file and every class has this get_code() method and most files have time_complexities() method. Are these truly necessary? Since python is open source, any user can simply open the file up and view the code.

  • time_complexities() seems somewhat unnecessary. Instead of storing the time complexity information in a method, why not store it in the file's docstrings or the methods docstrings?
    Example:

from pygorithm.sorting import bubble_sort
help(bubble_sort)

Help on module pygorithm.sorting.bubble_sort in pygorithm.sorting:

"""
NAME
    pygorithm.sorting.bubble_sort

DESCRIPTION
    Author: OMKAR PATHAK
    Contributors: Mohamed Kiouaz
    Created On: 31st July 2017
    
    Time Complexities:
     - Best O(n)
     - Average O(n*(n-1)/4)
     - Worst O(n^2)
"""

OR

from pygorithm.sorting import bubble_sort
help(bubble_sort.sort)
"""
Help on function sort in module pygorithm.sorting.bubble_sort:
sort(_list)
    Bubble Sorting algorithm
    
    Time Complexities:
     - Best O(n)
     - Average O(n*(n-1)/4)
     - Worst O(n^2)
    :param _list: list of values to sort
    :return: sorted values
"""

I think time_complexities() is necessary as some of the users may need it to display them right in the Python interpreter. Docstrings seems great idea to place time complexities but many users especially who are beginners dont know much about docstrings. Hence it would nice to keep time_complexities(). Removing modules.py would be a great idea though!