Skip to content

Commit

Permalink
Defer import of urllib.request to when its actually needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
purple4reina committed Jan 9, 2025
1 parent 76a9dd3 commit 9779c89
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datadog/util/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
from collections import UserDict as IterableUserDict
from io import StringIO
from urllib.parse import urlparse
import urllib.request as url_lib

class Urllib(object):
def __getattr__(self, name):
# defer the importing of urllib.request to when one of its
# attributes is accessed
import urllib.request
return getattr(urllib.request, name)
url_lib = Urllib()

imap = map
get_input = input
Expand Down

0 comments on commit 9779c89

Please sign in to comment.