Skip to content

Commit 520e9b1

Browse files
authored
Merge pull request faif#183 from elecay/master
Simpler and faster prototype
2 parents 2464352 + ca20fdc commit 520e9b1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

creational/prototype.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
import copy
5-
64

75
class Prototype(object):
86

97
value = 'default'
108

119
def clone(self, **attrs):
1210
"""Clone a prototype and update inner attributes dictionary"""
13-
obj = copy.deepcopy(self)
11+
# Python in Practice, Mark Summerfield
12+
obj = self.__class__()
1413
obj.__dict__.update(attrs)
1514
return obj
1615

0 commit comments

Comments
 (0)