From e2af07df446850483fd9f3c1edd0a7340d3510a8 Mon Sep 17 00:00:00 2001 From: Stijn Seghers Date: Thu, 16 Jan 2020 17:30:50 +1300 Subject: [PATCH] Keep pkg_resources import function-local (~0.06s) --- moto/core/responses.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/moto/core/responses.py b/moto/core/responses.py index c708edb8b..9a46f8ac5 100644 --- a/moto/core/responses.py +++ b/moto/core/responses.py @@ -20,7 +20,6 @@ import six from six.moves.urllib.parse import parse_qs, urlparse import xmltodict -from pkg_resources import resource_filename from werkzeug.exceptions import HTTPException import boto3 @@ -766,6 +765,9 @@ class AWSServiceSpec(object): """ def __init__(self, path): + # Importing pkg_resources takes ~60ms; keep it local + from pkg_resources import resource_filename # noqa + self.path = resource_filename("botocore", path) with io.open(self.path, "r", encoding="utf-8") as f: spec = json.load(f)