Skip to content

Commit

Permalink
Remove Unnecessary comprehension (#12221)
Browse files Browse the repository at this point in the history
The inbuilt functions all() and any() in python also support
short-circuiting (evaluation stops as soon as the overall return value
of the function is known), but this behavior is lost if you use
comprehension. This affects performance.
  • Loading branch information
kaxil authored Nov 10, 2020
1 parent 3ab5828 commit f8ae6e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ def remap_permissions():
if not appbuilder.sm.find_permission(old_perm_name):
continue
view_menus = appbuilder.sm.get_all_view_menu()
if not any(
[appbuilder.sm.find_permission_view_menu(old_perm_name, view.name) for view in view_menus]
):
if not any(appbuilder.sm.find_permission_view_menu(old_perm_name, view.name) for view in view_menus):
appbuilder.sm.del_permission(old_perm_name)


Expand Down
2 changes: 1 addition & 1 deletion dev/import_all_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def mk_prefix(provider_id):
def onerror(_):
nonlocal tracebacks
exception_string = traceback.format_exc()
if any([provider_prefix in exception_string for provider_prefix in provider_prefixes]):
if any(provider_prefix in exception_string for provider_prefix in provider_prefixes):
tracebacks.append(exception_string)

for modinfo in pkgutil.walk_packages(path=paths, prefix=prefix, onerror=onerror):
Expand Down

0 comments on commit f8ae6e5

Please sign in to comment.