Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

models allowing immutability #44

Merged
merged 7 commits into from Jun 13, 2017
Merged

models allowing immutability #44

merged 7 commits into from Jun 13, 2017

Conversation

samuelcolvin
Copy link
Member

@samuelcolvin samuelcolvin commented Jun 7, 2017

ref #38

This should also allow other cleanup including m.whatever = foobar updating __values__, it's also kind of necessary for #40 and copy(),

This also gives a slight (5 - 10%) performance increase instead of 10% decrease as the previous __setattr__ approach did.

It should also decrease memory footprint as __slots__ is used and __values__ is no longer duplicated.

@samuelcolvin samuelcolvin force-pushed the immutability branch 3 times, most recently from 18af130 to 129bd27 Compare June 10, 2017 17:11
@codecov
Copy link

codecov bot commented Jun 12, 2017

Codecov Report

Merging #44 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master    #44   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          10     10           
  Lines         701    691   -10     
  Branches      156    155    -1     
=====================================
- Hits          701    691   -10

@samuelcolvin
Copy link
Member Author

ready

@samuelcolvin samuelcolvin changed the title WIP: models allowing immutability models allowing immutability Jun 12, 2017
HISTORY.rst Outdated
v0.3.0 (TBC)
............
* immutable models via ``config.allow_mutation = False``, associated cleanup and performance improvement #44
* ``setatt`` is removed as ``__setattr__`` is not intelligent #44
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

pydantic/main.py Outdated
self.__values__[field] = value
setattr(self, field, value)
value = input_data[field]
values[field] = value
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant