Selectively assign the getter for better performance

Introduces the `inherit` param for FieldAttributes, which is now used
in BaseMeta when constructing the getter property to enhance performance
by reducing the amount of work the getter generally has to do.
This commit is contained in:
James Cammarata 2016-08-24 11:41:05 -05:00
commit 96e2be9bf8
3 changed files with 60 additions and 21 deletions

View file

@ -23,7 +23,7 @@ from copy import deepcopy
class Attribute:
def __init__(self, isa=None, private=False, default=None, required=False, listof=None, priority=0, class_type=None, always_post_validate=False):
def __init__(self, isa=None, private=False, default=None, required=False, listof=None, priority=0, class_type=None, always_post_validate=False, inherit=True):
self.isa = isa
self.private = private
@ -33,6 +33,7 @@ class Attribute:
self.priority = priority
self.class_type = class_type
self.always_post_validate = always_post_validate
self.inherit = inherit
if default is not None and self.isa in ('list', 'dict', 'set'):
self.default = deepcopy(default)