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] does prototype pattern have necessary to be exist in python patterns? #324

Open
zhengtong0898 opened this issue Apr 20, 2020 · 4 comments
Labels

Comments

@zhengtong0898
Copy link

@zhengtong0898 zhengtong0898 commented Apr 20, 2020

i can use copy.deepcopy() to copy a object in python,

does prototype pattern have necessary to be exist in python patterns?

@gyermolenko
Copy link
Contributor

@gyermolenko gyermolenko commented Apr 22, 2020

I agree.
copy.deepcopy works for arbitrary objects and custom classes.
And if we would want to customise that - we can define __deepcopy__ method (or .clone() just to make it as GoF describes)

Also couple of interesting thoughts here:
https://python-patterns.guide/gang-of-four/prototype/#the-prototype-pattern

@faif
Copy link
Owner

@faif faif commented Apr 22, 2020

I also agree. Feel free to add a pull request that replaces the current code with a deepcopy example

@crypdick
Copy link

@crypdick crypdick commented May 4, 2020

@faif in any case, shouldn't the existing example be using copy.deepcopy() in the clone method?

@faif faif added the question label May 4, 2020
@faif
Copy link
Owner

@faif faif commented May 4, 2020

@crypdick If there are no behaviour differences yes

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.