3 ms·
I don't know the internals of Python, but maybe checking if you need to refcount something is basically takes as long as actually just going ahead and doing it
by chrisseaton 9y ago
I don't know the internals of Python, but maybe checking if you need to refcount something is basically takes as long as actually just going ahead and doing it all the time anyway.
- throwaway613834 9y agoYeah you might be right, it's hard to say. Generally I view writing as more expensive than reading so I don't know.
- gvx 9y agoNote that it's not just write vs read, it's write vs read + branch.
- throwaway613834 9y agoRight, if it was just 1 read vs. 1 write then I would know!
- pythonaut_16 9y agoThat's also the same thought behind the Python practice of "it's better to ask forgiveness than permission". If you're going to have a conditional that will evaluate to True most of the time, sometimes (in Python) it's considered better to just go ahead and try the logic that the conditional is guarding, and then catch the exception and handle it if it happens.