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

[question]should the borg design pattern override __deepcopy__() ? #239

Closed
sak96 opened this issue Aug 20, 2018 · 3 comments
Closed

[question]should the borg design pattern override __deepcopy__() ? #239

sak96 opened this issue Aug 20, 2018 · 3 comments
Labels

Comments

@sak96
Copy link

sak96 commented Aug 20, 2018

  • 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
@sak96 sak96 changed the title should the borg design pattern override __deepcopy__() ? [question]should the borg design pattern override __deepcopy__() ? Aug 20, 2018
@faif faif added the question label Sep 3, 2018
@gyermolenko
Copy link
Contributor

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.

  1. "the singleton pattern is a software design pattern that restricts the instantiation of a class to one." (link)
  2. 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)

So I would say "not a bug". What do you think?

@sak96
Copy link
Author

sak96 commented Feb 8, 2019

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.

@sak96 sak96 closed this as completed Feb 8, 2019
@gyermolenko
Copy link
Contributor

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.

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

No branches or pull requests

3 participants