[Python-Dev] PEP 557: Data Classes (original) (raw)

Stéfane Fermigier sf at fermigier.com
Thu Oct 12 05:24:18 EDT 2017


On Thu, Oct 12, 2017 at 10:20 AM, Mike Miller <python-dev at mgmiller.net> wrote:

On 2017-10-12 00:36, Stéfane Fermigier wrote:

"An object that is not defined by its attributes, but rather by a thread of continuity and its identity." (from https://en.wikipedia.org/wiki/ Domain-drivendesign#Buildingblocks)

Not sure I follow all this, but Python objects do have identities once instantiated. e.g. >>> id('')

Yes, for the lifetime of the object in the Python VM.

But if you are dealing with objects that are persisted using some kind of ORM, ODM, OODB, then it wont work.

It's quite common (but not always the best solution) to use some kind of UUID to represent the identity of each entity.

Also, there can be circumstances where two objects can exist at the same time in the VM which represent the same object, in which case one should ensure that a == b iff a.uid == a.uid (in the case 'uid' is the attribute used to carry the unique identifier).

I don't believe either module particularly supports or restricts immutability?

http://www.attrs.org/en/stable/examples.html#immutability https://www.python.org/dev/peps/pep-0557/#frozen-instances

S.

-Mike


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/sfermigie r%2Blists%40gmail.com

-- Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier - http://linkedin.com/in/sfermigier Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/ Chairman, Free&OSS Group / Systematic Cluster - http://www.gt-logiciel-libre.org/ Co-Chairman, National Council for Free & Open Source Software (CNLL) - http://cnll.fr/ Founder & Organiser, PyData Paris - http://pydata.fr/


“You never change things by fighting the existing reality. To change something, build a new model that makes the existing model obsolete.” — R. Buckminster Fuller -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171012/785ec56b/attachment.html>



More information about the Python-Dev mailing list