No, there isn’t a datatype for dictionaries.

Converting to string via json.dumps() is one way, you can also convert to a
more compact string via something like cPickle.dumps(my_dict), or compress
it to e.g. zip and then dumps it, but as far as Maya is concerned they are
all of type string. Odds are you can convert it into any of the other
available types, like a huge number, but string isn’t a bad option; it’s
got no size limit (other than your total amount of RAM and disk space) and
probably isn’t posing any relevant performance overhead on its own in terms
of reading and writing to the attribute. The conversion between Maya and
Python can however be costly, and pickle is likely the faster option in
this case (depending on your data). The only thing to look out for with
that is that it will limit the result to machine-readable output (e.g.
Xz\939150\0klk5) and furthermore only be readable by the particular version
of Python you are running at the time of performing the dump. That is, if
you store a dumped pickle in Maya 2013 on Linux, odds are you can’t read it
in 2018 on Windows (or even the same version of Maya but on different OSes)
etc. On the other hand, you can pickle more than just dictionaries. Whole
classes and instanced PyMel nodes and what else have you.

You can see what Maya types are available as extra (i.e. “dynamic”)
attributes here
<http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/addAttr.html>
for example.
​

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA3GN9tH%3Dz13BwwVQo35fzkv63-c4iM3xuuSsmZxJ5f%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to