DotReferenceJythonMap is missing pop() method

When creating a chain of script transforms in a perspective binding, working with an array of dictionaries/documents is very troublesome, because Ignition converts the Python dictionaries into DotReferenceJythonMap objects after each transform step.

So let's say I have two transform scripts:

  • One for performing a calculation on the values
  • One for filtering the values

I have to start the second transform script with
value = [dict(x) for x in value[:]]
to convert the value back from an array of DotReferenceJythonMap objects to an array of python dictionaries, because their API is not equal. For example, the DotReferenceJythonMap does not have a pop() method.

So while there is a workaround, it increases the time complexity by N because I have to introduce another loop over the data which should not be needed otherwise.

Is there a better way to deal with this? Or is there a way to stop this conversion from happening?

Yes. Don't chain transforms. A script transform has substantial overhead, so only one should ever be attached to a binding. Instead, delegate to one or more project library scripts. (Nest the calls, so result from one is the value arg to the next. Do not use def or import inside a transform.)

Nope.

This is all discussed in some detail, with non-scripting alternatives, in my Integration Toolkit module topic (and its docs):

1 Like