[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-25 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: > This is already done in master branch ;) Thanks, I noticed the speed improvement in master and 3.7 but assumed it's due to some other optimisation in master. > Do you mind if I create PR for it? I would like to start contributing to > CPython ;)

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-25 Thread Marcel Zięba
Marcel Zięba added the comment: "It seems creating the signature of NonCallableMock.__init__ per mock creation is expensive and since it doesn't change can we just create the signature once and set it as a module level attribute? There might still be room for some more optimisations here to r

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-25 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Another point is that _spec_asyncs is a list of attributes that pass asyncio.iscoroutinefunction which could be also little expensive [0]. The check is made for the attribute to be async only when the child mock is created to return an AsyncMock [1

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-25 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks Marcel for the pointer. I can confirm the performance impact. This occurs in the common case where not being an AsyncMock the signature of NonCallableMock.__init__ is created every time and then bind_partial is used to detect the spec being

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-23 Thread Marcel Zięba
Marcel Zięba added the comment: This is the first commit I've observed slow down: 77b3b7701a34ecf6316469e05b79bb91de2addfa Especially this part looks suspicious https://github.com/python/cpython/commit/77b3b7701a34ecf6316469e05b79bb91de2addfa#diff-ff75b1b83c21770847ade91fa5bb2525R366

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-23 Thread Marcel Zięba
Marcel Zięba added the comment: I've also tested it and can confirm it. Master branch: raw times: 8.43 sec, 7.26 sec, 8.16 sec, 8.4 sec, 7.31 sec

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-22 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +xtreak ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue38895] performance degradation creating a mock object (by factor 7-8)

2019-11-22 Thread Julian
Change by Julian : -- title: performance degradation creating a mock object -> performance degradation creating a mock object (by factor 7-8) ___ Python tracker ___ __