From cd3183b395e812510765e8fa7e4c3ab573c6ce7a Mon Sep 17 00:00:00 2001 From: SergBobrovsky Date: Sat, 2 Jan 2021 16:56:40 +0300 Subject: [PATCH] refactor AppStack.default To check `if self` is cheaper than make `try except` block --- bottle.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bottle.py b/bottle.py index 23fff762..807c9846 100755 --- a/bottle.py +++ b/bottle.py @@ -2615,10 +2615,7 @@ def push(self, value=None): @property def default(self): - try: - return self[-1] - except IndexError: - return self.push() + return self[-1] if self else self.push() class WSGIFileWrapper(object):