]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Further improve get_rdata_class(). 442/head
authorBrian Wellington <bwelling@xbill.org>
Thu, 2 Apr 2020 17:32:57 +0000 (10:32 -0700)
committerBrian Wellington <bwelling@xbill.org>
Thu, 2 Apr 2020 17:32:57 +0000 (10:32 -0700)
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

index 1110e8f42129c688c61871f0289621873597acbd..4e5d36c33def397cf98ac366ea091d5db2bb86f8 100644 (file)
@@ -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