You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
borg as i see it is equivalent of singleton for python
but it does not handle deepcopy very well
shouldn't there be a __deepcopy__ method?
correct me if i am wrong
The text was updated successfully, but these errors were encountered:
sak96
changed the title
should the borg design pattern override __deepcopy__() ?
[question]should the borg design pattern override __deepcopy__() ?
Aug 20, 2018
hi @sak96
You are correct in notion that Borg does not handle deepcopy very well. Neither it does for shallow copy (copy.copy(..)).
But I don't think its his responsibility.
"the singleton pattern is a software design pattern that restricts the instantiation of a class to one." (link)
You can work around that: In order for a class to define its own copy implementation, it can define special methods __copy__() and __deepcopy__(). (link)
yes. I agree.
After reading more about data structure I would say sometime deep copy or copy may not be necessary. it is more to understand the essence of the pattern. back then when I had just started I felt that this was something which was worth thinking about. but now I look back and feel that most of the time you have to tweak a little bit for a pattern to be helpful.
Any how thanks for resolving my query.
great!
"but now I look back and feel that most of the time you have to tweak a little bit for a pattern to be helpful" - well said. Fits my experience as well.
The text was updated successfully, but these errors were encountered: