<commit_before>from copy import deepcopy

class Mud(object):
	def __init__(self, **kwargs):
		property_keys = [ k for k, v in self.__class__.__dict__.items() if type(v) is property ]
		for k in kwargs.keys():
			if k in ('__cache__', '__is_dirty__'):
				raise AttributeError('%s is a reserved variable' % k)
			# only update the appropriate class var if
			#	a.) var in self.__dict__
			#	b.) var is an @property (var in self.__class__.__dict__)
			#	if var is @property, the appropriate @var.setter is called to
			#	update the object instance appropriately (if property.fset exists)
			# cf. http://bit.ly/1qO35ig
			if k in property_keys:
				# ensure the property is not read only -- there exists an X.setter for this property
				# cf. http://bit.ly/1spbmLm
				if self.__class__.__dict__[k].fset != None:
					try:
						setattr(self, k, kwargs.pop(k))
					# catch all calls which may be deprecated, unsupported, etc.
					except NotImplementedError:
						pass
			elif k in self.__dict__:
				setattr(self, k, kwargs.pop(k))

		self.__dict__['__is_dirty__'] = False
		self.__dict__['__cache__'] = {}

	def __setattr__(self, k, v):
		if k in ('__cache__', '__is_dirty__'):
			raise AttributeError('%s is a reserved variable' % k)

		# calling Derived.var = val before calling Mud.__init__
		if '__is_dirty__' not in self.__dict__:
			self.__dict__['__is_dirty__'] = False
		if '__cache__' not in self.__dict__:
			self.__dict__['__cache__'] = {}

		# adding to the cache only if __is_dirty__ is not yet set
		if not self.__dict__['__is_dirty__']:
			# new variables
			if (k not in self.__dict__) and (k not in [ key for key, val in self.__class__.__dict__.items() if type(val) is property ]):
				self.__dict__['__is_dirty__'] = True
			# only add an entry to the cache if the property already exists
			elif k not in self.__dict__['__cache__']:
				self.__dict__['__cache__'][k] = deepcopy(getattr(self, k, None))
		super(Mud, self).__setattr__(k, v)

	def __getattribute__(self, k):
		if k in ('__cache__', '__is_dirty__'):
			raise AttributeError('%s is a reserved variable' % k)
		if k in ('__dict__', '__class__'):
			return super(Mud, self).__getattribute__(k)

		# calling Derived.var before calling Mud.__init__
		if '__is_dirty__' not in self.__dict__:
			self.__dict__['__is_dirty__'] = False
		if '__cache__' not in self.__dict__:
			self.__dict__['__cache__'] = {}

		if not self.__dict__['__is_dirty__'] and k != 'is_dirty':
			if k not in self.__dict__['__cache__']:
				# saves a copy of the field at time of access
				self.__dict__['__cache__'][k] = deepcopy(super(Mud, self).__getattribute__(k))

		return super(Mud, self).__getattribute__(k)

	@property
	def is_dirty(self):<commit_msg>added more reserved variable names to return unquestionably in Mud.__getattribute__<commit_after>from copy import deepcopy

class Mud(object):
	def __init__(self, **kwargs):
		property_keys = [ k for k, v in self.__class__.__dict__.items() if type(v) is property ]
		for k in kwargs.keys():
			if k in ('__cache__', '__is_dirty__'):
				raise AttributeError('%s is a reserved variable' % k)
			# only update the appropriate class var if
			#	a.) var in self.__dict__
			#	b.) var is an @property (var in self.__class__.__dict__)
			#	if var is @property, the appropriate @var.setter is called to
			#	update the object instance appropriately (if property.fset exists)
			# cf. http://bit.ly/1qO35ig
			if k in property_keys:
				# ensure the property is not read only -- there exists an X.setter for this property
				# cf. http://bit.ly/1spbmLm
				if self.__class__.__dict__[k].fset != None:
					try:
						setattr(self, k, kwargs.pop(k))
					# catch all calls which may be deprecated, unsupported, etc.
					except NotImplementedError:
						pass
			elif k in self.__dict__:
				setattr(self, k, kwargs.pop(k))

		self.__dict__['__is_dirty__'] = False
		self.__dict__['__cache__'] = {}

	def __setattr__(self, k, v):
		if k in ('__cache__', '__is_dirty__'):
			raise AttributeError('%s is a reserved variable' % k)

		# calling Derived.var = val before calling Mud.__init__
		if '__is_dirty__' not in self.__dict__:
			self.__dict__['__is_dirty__'] = False
		if '__cache__' not in self.__dict__:
			self.__dict__['__cache__'] = {}

		# adding to the cache only if __is_dirty__ is not yet set
		if not self.__dict__['__is_dirty__']:
			# new variables
			if (k not in self.__dict__) and (k not in [ key for key, val in self.__class__.__dict__.items() if type(val) is property ]):
				self.__dict__['__is_dirty__'] = True
			# only add an entry to the cache if the property already exists
			elif k not in self.__dict__['__cache__']:
				self.__dict__['__cache__'][k] = deepcopy(getattr(self, k, None))
		super(Mud, self).__setattr__(k, v)

	def __getattribute__(self, k):
		if k in ('__cache__', '__is_dirty__'):
			raise AttributeError('%s is a reserved variable' % k)

		# reserved, read-only attributes
		# cf. http://bit.ly/UUml3F
		if k in ('__dict__', '__class__', '__bases__', '__name__', '__mro__'):
			return super(Mud, self).__getattribute__(k)

		# calling Derived.var before calling Mud.__init__
		if '__is_dirty__' not in self.__dict__:
			self.__dict__['__is_dirty__'] = False
		if '__cache__' not in self.__dict__:
			self.__dict__['__cache__'] = {}

		if not self.__dict__['__is_dirty__'] and k != 'is_dirty':
			if k not in self.__dict__['__cache__']:
				# saves a copy of the field at time of access
				self.__dict__['__cache__'][k] = deepcopy(super(Mud, self).__getattribute__(k))

		return super(Mud, self).__getattribute__(k)

	@property
	def is_dirty(self):
{'fraction_non_alphanumeric': 0.12109305233077335, 'fraction_numerical': 0.0016074298981961065, 'mean_word_length': 3.810996563573883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3879641', 'n_tokens_mistral': 2136, 'n_tokens_neox': 1897, 'n_words': 598}