Apr-28-2017, 06:07 AM
I'm not against increasing the performance of code when it makes sense. But I suspect a decorator is a better solution than a hack with default arguments.
empty arguments
|
Apr-28-2017, 06:07 AM
I'm not against increasing the performance of code when it makes sense. But I suspect a decorator is a better solution than a hack with default arguments.
Apr-28-2017, 09:47 AM
(Apr-28-2017, 06:07 AM)micseydel Wrote: I'm not against increasing the performance of code when it makes sense. But I suspect a decorator is a better solution than a hack with default arguments.You would be very surprised, but the hack in question was implemented in the internal function of 2-layered decorator. Decorated functions had to be able to share cache - that why I couldn't use closure. And class decorator did not work for some reason - I don't remember why. I am not overfond of hacks - they may be a major pain in the ass, especially when those are not documented (I've seen one or two, well - some people strive for job security ![]() On the other hand - if BDFL in his "for-life" wisdom ![]()
Test everything in a Python shell (iPython, Azure Notebook, etc.)
May-11-2017, 04:03 PM
When I've wanted caching, I just used a decorator. Using something that might be an implementation detail feels susfishous to me.
Do lists in function arguments work that way in other versions of python, like pypy or ironpython? I don't have anything but cpython installed at work to test it.
May-11-2017, 05:20 PM
(May-11-2017, 04:03 PM)nilamo Wrote: When I've wanted caching, I just used a decorator. Using something that might be an implementation detail feels susfishous to me. I don't know, there are some think like system limitations? Compensation for design deficiencies?! If every problem could have been solved by trivial methods ![]()
Test everything in a Python shell (iPython, Azure Notebook, etc.)
May-11-2017, 05:31 PM
I can't cite anything, but I'm fairly certain that it's a language spec and not an implementation detail, so unless you find evidence that it really is implementation-specific I wouldn't cite that as a reason.
May-11-2017, 05:36 PM
Can we stop the pissing content
![]()
Test everything in a Python shell (iPython, Azure Notebook, etc.)
May-11-2017, 10:37 PM
Do you mean pissing contest? I don't see that here, though I didn't realize we got off topic. If people want to continue the discussion about mutable default arguments being a hack or not, that should probably be a separate thread.
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) | Adelton | 2 | 4,605 |
Mar-02-2017, 10:23 PM Last Post: zivoni |