Skip to content

Conversation

@elecay
Copy link
Contributor

@elecay elecay commented Mar 28, 2017

A basic performance test:

if name == 'main':
import time

for _ in range(10):
    n = 10000
    t0 = time.time()
    for i in range(n):
        main()
    t1 = time.time()

    total_n = t1 - t0
    print(total_n)

Results:

copy.deepcopy()

0.5343360900878906
0.3827991485595703
0.335590124130249
0.3641550540924072
0.3552978038787842
0.39732789993286133
0.4047999382019043
0.35767602920532227
0.40660595893859863
0.3223540782928467

class

0.056986093521118164
0.04783987998962402
0.04845404624938965
0.043087005615234375
0.04816293716430664
0.051603078842163086
0.046478986740112305
0.044046878814697266
0.048792123794555664
0.05028414726257324

A basic performance test:

if __name__ == '__main__':
    import time

    for _ in range(10):
        n = 10000
        t0 = time.time()
        for i in range(n):
            main()
        t1 = time.time()

        total_n = t1 - t0
        print(total_n)

Results:

copy.deepcopy()

0.5343360900878906
0.3827991485595703
0.335590124130249
0.3641550540924072
0.3552978038787842
0.39732789993286133
0.4047999382019043
0.35767602920532227
0.40660595893859863
0.3223540782928467

__class__

0.056986093521118164
0.04783987998962402
0.04845404624938965
0.043087005615234375
0.04816293716430664
0.051603078842163086
0.046478986740112305
0.044046878814697266
0.048792123794555664
0.05028414726257324
@codecov-io
Copy link

codecov-io commented Mar 28, 2017

Codecov Report

Merging #183 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #183      +/-   ##
==========================================
- Coverage   94.51%   94.51%   -0.01%     
==========================================
  Files          55       55              
  Lines        2334     2333       -1     
==========================================
- Hits         2206     2205       -1     
  Misses        128      128
Impacted Files Coverage Δ
creational/prototype.py 96.29% <100%> (-0.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2464352...ca20fdc. Read the comment docs.

@faif
Copy link
Owner

faif commented Apr 3, 2017

Hi,

Thanks for the commit. Do you think that keeping the original implementation makes any sense? For example, are there any cases where deepcopy would work but your implementation wouldn't?

@elecay
Copy link
Contributor Author

elecay commented Apr 3, 2017

Hi.

No, there isn't. So, that's is why class it's prefered to deepcopy. Keeping the original make no sense.

@faif faif merged commit 520e9b1 into faif:master Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants