[Erp5-dev] [Erp5-report] r25395 - /erp5/trunk/products/ERP5/TargetSolver/SplitAndDefer.py

Julien Muchembled jm at nexedi.com
Fri Jan 30 18:52:14 CET 2009


Hi,


nobody at svn.erp5.org a écrit :
> Author: jerome
> Date: Fri Jan 30 18:19:22 2009
> New Revision: 25395
> 
> URL: http://svn.erp5.org?rev=25395&view=rev
> Log:
> don't use "in objectIds" which is O(n)

Actually, that's what I thought, and I told that to Jerome.
After looking at Zope source code, it seems I was wrong. I mean that the object returned by objectIds() wouldn't be a simple iterator, but would also provide an intelligent __contains__ method.

Can anyone confirm that
  new_id in applied_rule.objectIds()
is as fast as
  getattr(aq_base(applied_rule), new_id, None) is not None
from a complexity point of view ?


Julien


> Modified:
>     erp5/trunk/products/ERP5/TargetSolver/SplitAndDefer.py
> 
> Modified: erp5/trunk/products/ERP5/TargetSolver/SplitAndDefer.py
> URL: http://svn.erp5.org/erp5/trunk/products/ERP5/TargetSolver/SplitAndDefer.py?rev=25395&r1=25394&r2=25395&view=diff
> ==============================================================================
> --- erp5/trunk/products/ERP5/TargetSolver/SplitAndDefer.py [utf8] (original)
> +++ erp5/trunk/products/ERP5/TargetSolver/SplitAndDefer.py [utf8] Fri Jan 30 18:19:22 2009
> @@ -54,7 +54,7 @@
>        split_index = 0
>        new_id = "%s_split_%s" % (simulation_movement.getId(), split_index)
>        applied_rule = simulation_movement.getParentValue()
> -      while new_id in applied_rule.objectIds():
> +      while getattr(aq_base(applied_rule), new_id, None) is not None:
>          split_index += 1
>          new_id = "%s_split_%s" % (simulation_movement.getId(), split_index)
>        # Adopt different dates for deferred movements
> 
> _______________________________________________
> Erp5-report mailing list
> Erp5-report at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-report




More information about the Erp5-dev mailing list