mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 01:36:32 +01:00
Went over the Command class' basic methods, cleaning up and optimizing while still trying to keep things clean, such as using cleverer loops and try...except instead of if statements. Also cleaned up the way attributes are retrieved. Results in roughly a halving of the time that the code spends in the command.py module.
This commit is contained in:
parent
7b2a4e4467
commit
d36a79b2cc
3 changed files with 27 additions and 46 deletions
|
|
@ -24,15 +24,6 @@ def is_iter(iterable):
|
|||
"""
|
||||
return hasattr(iterable, '__iter__')
|
||||
|
||||
# if isinstance(iterable, basestring):
|
||||
# # skip all forms of strings (str, unicode etc)
|
||||
# return False
|
||||
# try:
|
||||
# # check if object implements iter protocol
|
||||
# return iter(iterable)
|
||||
# except TypeError:
|
||||
# return False
|
||||
|
||||
def fill(text, width=78, indent=0):
|
||||
"""
|
||||
Safely wrap text to a certain number of characters.
|
||||
|
|
@ -396,7 +387,7 @@ def inherits_from(obj, parent):
|
|||
parent_path = "%s.%s" % (parent.__module__, parent.__name__)
|
||||
else:
|
||||
parent_path = "%s.%s" % (parent.__class__.__module__, parent.__class__.__name__)
|
||||
return any(True for obj_path in obj_paths if obj_path == parent_path)
|
||||
return any(1 for obj_path in obj_paths if obj_path == parent_path)
|
||||
|
||||
|
||||
def format_table(table, extra_space=1):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue