Could you also assign the serialized dictionary to blind data on nodes? I
can't remember of the top of my head which data types are supported.

On Sat, Mar 3, 2018 at 1:59 AM, Marcus Ottosson <konstrukt...@gmail.com>
wrote:

> then it should be able to be dumped on Maya 2013 in Linux and read in Maya
> 2018 on Windows.
>
> TLDR; compiler differences and unavailable internal datastructures.
>
> For starters, one thing that could be confusing is how there is pickle
> and then there is cPickle. pickle is a pure Python library which I expect
> have no trouble with cross-platform compatibility. cPickle on the other
> hand is a compiled library and, like anything compiled, I’d expect the same
> incompatibility as with it as with e.g. PyQt unless it’s compiled for the
> particular version of Maya’s Python interpreter, and the same for NumPy and
> friends. (Can this be *not* true?)
>
> However aside from that, with both pickle and cPickle you are still
> serialising internal data structures and not all datastructures on Linux
> are available on Windows, not all in Maya 2013 are available in Maya 2018.
> In the simplest case of incompatibility, you could pickle a PyMEL object in
> Maya 2018 that hasn’t yet been invented in 2013, or a MASH object that
> didn’t exist in 2013. Or pickle some instance of one of your own plug-ins,
> that you’ve got a different version of on another computer.
>
> I would think that the only way to be safe in a multi-OS, multi-Maya
> environment, is to both stick with pickle (not cPickle) *and* ensure your
> data is JSON-serialisable to begin with (no complex data). But in that
> case, you’ve run out of reasons to use pickle over json anyway.
>
> Taking a closer look at the documentation, I also spotted..
>
> The pickle serialization format is guaranteed to be backwards compatible
> across Python releases.
>
> Which I would read “data pickled in Maya 2013 is guaranteed to be
> compatible with Maya 2018”, but not the other way around (that would be
> *forwards* compatibility). This, I think, would invalidate even the
> “safe” option I listed just now.
>
> With all this said, I did expect to find larger warning signs explicitly
> written out in both the Python docs and community, but can’t seem to find a
> conclusive answer. So with that in mind, I’ll change my position from “Odds
> are you will run into trouble” to “Odds are you *may* run into trouble”.
> Would you agree?
> ​
>
> On 2 March 2018 at 20:54, Justin Israel <justinisr...@gmail.com> wrote:
>
>>
>>
>> On Sat, Mar 3, 2018, 5:52 AM Marcus Ottosson <konstrukt...@gmail.com>
>> wrote:
>>
>>> 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.
>>>
>> Why would that be true? If you specify the protocol when you read and
>> write the cPickle data, then it should be able to be dumped on Maya 2013 in
>> Linux and read in Maya 2018 on Windows.
>>
>> https://docs.python.org/2/library/pickle.html#data-stream-format
>>
>> One could stick with binary protocol 2 the whole way through, I would
>> think. Am I wrong?
>>
>>
>> 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/ms
>>> gid/python_inside_maya/CAFRtmOA3GN9tH%3Dz13BwwVQo35fzkv63-c4
>>> iM3xuuSsmZxJ5f%3Dw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA3GN9tH%3Dz13BwwVQo35fzkv63-c4iM3xuuSsmZxJ5f%3Dw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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/ms
>> gid/python_inside_maya/CAPGFgA38%2BW2k7W1bpMYsnnincG9S%2BgS2
>> uW9Fknh5rCpnYHuFtA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA38%2BW2k7W1bpMYsnnincG9S%2BgS2uW9Fknh5rCpnYHuFtA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CAFRtmODAvy8To4jCAk-n%
> 3DvffzPFKGLiQu%2B19RCgapnLG%2BF%3DBKw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODAvy8To4jCAk-n%3DvffzPFKGLiQu%2B19RCgapnLG%2BF%3DBKw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"God is a metaphor for a mystery that absolutely transcends all human
categories of thought. It's as simple as that!" - Joseph Campbell

-- 
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/CAP_aC5a_KEaF3VmyX%2BX36cTaM_rBu7H0pCT8J6dBV%3D6cL7DgTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to