From: Brian Wellington Date: Thu, 2 Apr 2020 17:32:57 +0000 (-0700) Subject: Further improve get_rdata_class(). X-Git-Tag: v2.0.0rc1~308^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=331358ba1d336f0e63d78d2b3aa78ec07a020f6b;p=thirdparty%2Fdnspython.git Further improve get_rdata_class(). When we find a class-independent type, cache it for both class ANY and the requested type, to avoid an extra dict lookup the next time. If we don't find anything, cache GenericRdata, to avoid extra module loads the next time. --- diff --git a/dns/rdata.py b/dns/rdata.py index 1110e8f4..4e5d36c3 100644 --- a/dns/rdata.py +++ b/dns/rdata.py @@ -339,10 +339,12 @@ def get_rdata_class(rdclass, rdtype): 'ANY', rdtype_text])) cls = getattr(mod, rdtype_text) _rdata_classes[(dns.rdataclass.ANY, rdtype)] = cls + _rdata_classes[(rdclass, rdtype)] = cls except ImportError: pass if not cls: cls = GenericRdata + _rdata_classes[(rdclass, rdtype)] = cls return cls