This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Daniel Lindeman
Recipients Daniel Lindeman, eric.smith
Date 2018-05-15.04:20:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526358040.67.0.682650639539.issue33474@psf.upfronthosting.co.za>
In-reply-to
Content
A possible use case would be a field that represents an auto-incrementing database ID. Since the field is auto-incrementing in the database, it would be desirable to keep this field frozen, and others mutable once an instance of a data class is created. 

This is also a feature of data classes in other languages, for example Kotlin: https://kotlinlang.org/docs/reference/data-classes.html . The main difference here being that we don't have val and var, and thus mutability and immutability are harder to represent.

Hashing could be implemented such that frozen fields are allowed to be part of the hash, but unfrozen fields would remain only part of the hash when unsafe_hash is set. I believe equality follows from hashing, so the same rules should apply. 

The conflict between setting the class to frozen, and a field to not frozen could be solved by raising an exception.

Upon investigation, attrs does not support this behavior. I can try this feature with attrs, but their implementation may differ enough to make it infeasible.
History
Date User Action Args
2018-05-15 04:20:40Daniel Lindemansetrecipients: + Daniel Lindeman, eric.smith
2018-05-15 04:20:40Daniel Lindemansetmessageid: <1526358040.67.0.682650639539.issue33474@psf.upfronthosting.co.za>
2018-05-15 04:20:40Daniel Lindemanlinkissue33474 messages
2018-05-15 04:20:40Daniel Lindemancreate