forked from lyft/toasted-marshmallow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cache JIT methods between executions
This is quite a dangerous change, but it's pretty much the only thing we can do to speedup serialization of long lists of nested Schemas without modifying Marshmallow's core code. We don't want to do that.
- Loading branch information
Showing
2 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
import logging | ||
import os | ||
|
||
if os.getenv("DFM_LOG_LEVEL", None) is not None: | ||
logger = logging.getLogger("DeepFriedMarshmallow") | ||
|
||
logger = logging.getLogger("DeepFriedMarshmallow") | ||
sh = logging.StreamHandler() | ||
sh.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s] [Deep-Fried Marshmallow] %(message)s")) | ||
if logger.level == logging.NOTSET: | ||
try: | ||
logger.setLevel(os.getenv("DFM_LOG_LEVEL", logging.WARN)) | ||
except ValueError: | ||
logger.setLevel(logging.WARN) | ||
|
||
if logger.level == logging.NOTSET: | ||
try: | ||
logger.setLevel(os.getenv("DFM_LOG_LEVEL", logging.WARN)) | ||
sh.setLevel(os.getenv("DFM_LOG_LEVEL", logging.WARN)) | ||
except ValueError: | ||
logger.setLevel(logging.WARN) | ||
sh.setLevel(logging.WARN) | ||
sh = logging.StreamHandler() | ||
sh.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s] [Deep-Fried Marshmallow] %(message)s")) | ||
sh.setLevel(logging.DEBUG) | ||
logger.addHandler(sh) | ||
else: | ||
|
||
logger.addHandler(sh) | ||
class DummyLogger: | ||
def __getattr__(self, item): | ||
def noop(*args, **kwargs): | ||
pass | ||
|
||
return noop | ||
|
||
logger = DummyLogger() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters