Nobody cares but I just wanna get this out of my system because comments are the devil
Bad code, you'll return to it in a few weeks and wonder what the hell you were doing. Code does not execute faster because you use short names for your variables and functions
def k(p):
del p
def run():
p = "steve"
k(p)
That could be improved by not using comments, instead using the comments as inspiration for variable/function names, adding type hints, using classes, adding docstrings
class Player:
"""A player in the game"""
name: str
def kill_player(player: Player):
"""Kills a player"""
del player
def main_loop():
"""Main loop of the game"""
player = Player("steve")
kill_player(player)
Better code, if you don't know what's going on in a few weeks you're probably just not reading the code
class Player:
"""A player in the game"""
name: str
class TheGame:
"""The game"""
def main_loop(self):
"""Main loop of the game"""
player = self.create_player("steve")
self.kill_player(player)
@staticmethod
def create_player(name: str) > Player:
return Player(name)
@staticmethod
def kill_player(player: Player):
"""Kills a player"""
del player
"But Simon my function is 200 lines long the docstring isn't enough to describe it all" then you're using functions wrong, they should be short and specific in what they do, functions should only do at most like 4-5 things, 10 at most. You can easily write a docstring that explains what the next 4-5 lines of code is gonna be doing
The reason you need comments is because your context is too large and you aren't using easily readable names. Make your contexts smaller and more modular, comments are just bloating your codebase and risking confusing people