Parameter Attribute as Dictionary

One of the most asked questions about Python is "I only have the name of my parameter as a string. How can I acces it?
Normaly the answer is getattr() but it is pretty slow compared to direct acces to the parameter.
It would be really great if the par attribute of an operator could also be handled as a dictionary (or a par_dict member) so it would look:


This would be a useful addition.
In the meantime, you could use : op(‘myOperator’).pars(‘Float’)[0]

This was one of the question on my last blogpost and doing some testing I found set/getattr to be way ahead of pars(“Float”)[0]

And accesing the the par directly or by dict is just so so much faster :slight_smile:

That’s a really great analysis.
I suppose pars is slower in that it creates a list, and searches for all possibilities that match the pattern.
Looks like it can be improved.

Do you have that toe file handy for testing?

Im affraid no, was just a quick scetch somewhere in my project to visualise the situation :\

Not a problem, the info you laid out is very clear.

Alright, builds 2020.23060 and later now support:

Example: op(‘base’).par[‘MyFloat’] = 3.5

In my testing it was about 15x faster than using[name][0]



Dang, that was fast. Really great an appriciated!*
edit: Just wondering. Is it name or label?

Great catch. It’s by name. I’ve edited my post.
The other lingering change we’ve contemplated is making OP.par iterable.
op(‘geo1’).par instead of op(‘geo1’).pars(’*’)