From 331358ba1d336f0e63d78d2b3aa78ec07a020f6b Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Thu, 2 Apr 2020 10:32:57 -0700 Subject: [PATCH] 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. --- dns/rdata.py | 2 ++ 1 file changed, 2 insertions(+) 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 -- 2.47.3