[Checkins] SVN: z3c.form/trunk/src/z3c/form/field.py Optimize calls to alsoProvides

Brian Sutherland jinty at web.de
Sat Mar 15 13:56:11 EDT 2008


Log message for revision 84663:
  Optimize calls to alsoProvides
  
  Setting both interfaces with alsoProvides at the same time reliably shaves 0.1
  seconds from the render time of a form with ~180 widgets on my laptop.
  

Changed:
  U   z3c.form/trunk/src/z3c/form/field.py

-=-
Modified: z3c.form/trunk/src/z3c/form/field.py
===================================================================
--- z3c.form/trunk/src/z3c/form/field.py	2008-03-15 15:02:20 UTC (rev 84662)
+++ z3c.form/trunk/src/z3c/form/field.py	2008-03-15 17:56:11 UTC (rev 84663)
@@ -246,10 +246,10 @@
             widget.id = (prefix + shortName).replace('.', '-')
             # Step 4: Set the context
             widget.context = self.content
-            zope.interface.alsoProvides(widget, interfaces.IContextAware)
             # Step 5: Set the form
             widget.form = self.form
-            zope.interface.alsoProvides(widget, interfaces.IFormAware)
+            # Optimization: set both interfaces here, rather in step 4 and 5: alsoProvides is quite slow
+            zope.interface.alsoProvides(widget, interfaces.IContextAware, interfaces.IFormAware)
             # Step 6: Set some variables
             widget.ignoreContext = self.ignoreContext
             widget.ignoreRequest = self.ignoreRequest



More information about the Checkins mailing list