NitkarshChourasia / fun_py

fun Python puzzles to boost creativity and logic building.
0 stars 0 forks source link

Code Performance Optimization and Request for Code Review #1

Open OfficialAhmed opened 1 year ago

OfficialAhmed commented 1 year ago

Instead of generating a list of lowercase letters for checking a better implementation is the islower() method. You may get rid of the following block of code to a simple one line

lowercase_characters = [chr(ele) for ele in range(97, 97 + 26)]

for char in word:
    if char not in lowercase_characters:
        return "Only lowercase letters are allowed"

# islower() checks the entire string if all char(s) lower case
if not islower(text_to_check):
    return "Only lowercase letters are allowed"

Eliminating the for-loop reduces the steps executed, hence faster code execution Eliminating the list comprehension and checking reduces steps executed, hence faster code execution Not to mention the code is more user-friendly and easy to read

NitkarshChourasia commented 1 year ago

Hey there, Ahmed!

First of all, I want to apologize for closing your pull requests. I realized that I need to work on this bunch of Python programs myself to get things sorted out. However, I really appreciated your effort in reviewing my code, and I believe you got a good idea of what the Python folder contains.

Now, I'd like to invite you to become my explicit code reviewer. I value your expertise and insights, and having you review my code will be immensely helpful for improving the quality and readability of my programs.

But, how should I add you as my explicit code reviewer? Where are the option, I can't seem to find it. Best regards, Nitkarsh Chourasia

NitkarshChourasia commented 1 year ago

So, Ahmed. What languages are you efficient with?

OfficialAhmed commented 1 year ago

Hi there, here is how you can add reviewers Add default reviewers

I know a lot of languages including JS, Swift, PHP.. Im trying to stick with Python on Github