From 544ca174ad5e9d9b5902dd51e48ac5aa5c3bf6e5 Mon Sep 17 00:00:00 2001
From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl>
Date: Thu, 11 May 2017 13:49:19 +0200
Subject: [PATCH] 0.91

---
 .../compilation/compile_definitions.py        |  4 ++--
 coolamqp/framing/definitions.py               | 19 ++++++++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/coolamqp/framing/compilation/compile_definitions.py b/coolamqp/framing/compilation/compile_definitions.py
index 0109147..62a957d 100644
--- a/coolamqp/framing/compilation/compile_definitions.py
+++ b/coolamqp/framing/compilation/compile_definitions.py
@@ -55,7 +55,7 @@ binary string? It's a memoryview all right.
 Only thing that isn't are field names in tables.
 """
 
-import struct, collections, warnings, logging, six
+import struct, collections, logging, six
 
 from coolamqp.framing.base import AMQPClass, AMQPMethodPayload, AMQPContentPropertyList
 from coolamqp.framing.field_table import enframe_table, deframe_table, frame_table_size
@@ -230,7 +230,7 @@ Field = collections.namedtuple('Field', ('name', 'type', 'basic_type', 'reserved
 #
 #       If you do not know in advance what properties you will be using, it is correct to use
 #       this constructor.
-
+        if zpf in BasicContentPropertyList.PARTICULAR_CLASSES:
             return %s.PARTICULAR_CLASSES[zpf](**kwargs)
         else:
             logger.debug('Property field (%s:%d) not seen yet, compiling', repr(zpf))
diff --git a/coolamqp/framing/definitions.py b/coolamqp/framing/definitions.py
index cab1e07..e472c3d 100644
--- a/coolamqp/framing/definitions.py
+++ b/coolamqp/framing/definitions.py
@@ -23,7 +23,7 @@ binary string? It's a memoryview all right.
 Only thing that isn't are field names in tables.
 """
 
-import struct, collections, warnings, logging, six
+import struct, collections, logging, six
 
 from coolamqp.framing.base import AMQPClass, AMQPMethodPayload, AMQPContentPropertyList
 from coolamqp.framing.field_table import enframe_table, deframe_table, frame_table_size
@@ -2359,6 +2359,23 @@ class BasicContentPropertyList(AMQPContentPropertyList):
         ])
         zpf = six.binary_type(zpf)
 
+#        If you know in advance what properties you will be using, use typized constructors like
+#
+#          runs once
+#            my_type = BasicContentPropertyList.typize('content_type', 'content_encoding')
+#
+#           runs many times
+#            props = my_type('text/plain', 'utf8')
+#
+#       instead of
+#
+#           # runs many times
+#           props = BasicContentPropertyList(content_type='text/plain', content_encoding='utf8')
+#
+#       This way you will be faster.
+#
+#       If you do not know in advance what properties you will be using, it is correct to use
+#       this constructor.
         if zpf in BasicContentPropertyList.PARTICULAR_CLASSES:
             return BasicContentPropertyList.PARTICULAR_CLASSES[zpf](**kwargs)
         else:
-- 
GitLab