Okay you are my hero Alok !
with your approach looping 10 times on this function went from 1min5sec to
6sec !

thanks a lot !


On 27 July 2012 16:09, Jeremie Passerin <[email protected]> wrote:

> Thanks Matt !
>
> Interesting solution Alok, my issue is not the 2sec that it takes to
> perform the seach but that I am looping on this method about 20 times... so
> it makes sense to try something like that ! I'll give it a try right now !
>
>
> On 27 July 2012 15:54, Alok <[email protected]> wrote:
>
>>  Maybe globally store the expressions with their params in a hash
>> (dictionary in Python) and then do the reverse look up. Will not run
>> faster but will save you time for each call to
>> getExpressionsDrivenByParameter()
>>
>> In this case:
>> PARAM_EXPR_DICT = {}
>> for expr in Application.FindObjects(None,
>> "{12723EB2-7DDB-11D0-A57F-00A0C91412DE}"):
>>     ports = expr.InputPorts
>>     if not ports.Count:
>>         continue
>>     for port in in ports :
>>         paramName = port.Target2.FullName
>>         if not PARAM_EXPR_DICT.has_key(paramName):
>> PARAM_EXPR_DICT[paramName] = []
>>         PARAM_EXPR_DICT[paramName].append(expr)
>>
>>
>> Then you can test it for parameter simply by:
>> def getExpressionsDrivenByParameter( param ):
>>     return (PARAM_EXPR_DICT[param.FullName] if
>> PARAM_EXPR_DICT.has_key(param.Name) else None)
>>
>>
>>
>>
>> Alok.
>>
>>  On 27/07/2012 5:44 PM, Jeremie Passerin wrote:
>>
>> Hi guys,
>>
>>  I was wondering what is your technique to get all the expressions
>> driven by a parameter.
>> I'm trying to find the fastest way to do it.
>> here is my code :
>>
>>  def getExpressionsDrivenByParameter( param ):
>>
>>  allExpressions = xsi.FindObjects(None,
>> "{12723EB2-7DDB-11D0-A57F-00A0C91412DE}")
>>   result = []
>>  for exp in allExpressions:
>>  for port in exp.InputPorts:
>>  if port.Target2.IsEqualTo(param) and exp.OutputPorts.Count:
>>  result.append(exp)
>>  break
>>   return result
>>
>>  With around 5000 expressions in my scene it takes about 2sec to get the
>> result. Anyone got a faster solution ?
>>
>>  cheers,
>> Jeremie
>>
>> No virus found in this message.
>> Checked by AVG - www.avg.com
>> Version: 2012.0.2197 / Virus Database: 2437/5158 - Release Date: 07/27/12
>>
>>
>>
>

Reply via email to