I'll limit this question to a specific example that I have seen multiple times on the python tag, but I would imagine it applies in many places.
Someone posts a big question that goes into loads of detail about what they are trying to do, but it's not so ridiculously abstract as to be closed as "too broad" (IMO, and I vote to close a reasonable amount each day). They have code but it takes 4 hours, say, to execute a list lookup - if x in some_mega_list:
is in their code somewhere and, to people familiar with the language, it's an obvious bottleneck. Making one change probably fixes the issue; just convert it to a set
for O(1) lookup... problem solved.
There's a number of factors here that leave me conflicted in how to deal with this situation:
- Python is gaining huge momentum in data science/analytics. If this were a NumPy question, no question would be punted to Code Review for running too slow; anything that doesn't run as fast as possible is basically broken and is usually upvoted (...and will also carry the python` tag). Even if vanilla python code takes 4 hours to produce the correct output, I'd probably still consider it broken myself if it could be done in secs/minutes from a simple change. We have SLAs and KPIs. NumPy code will surely rely on pure Python for integration into a broader system so speed should be a consideration throughout.
- I could answer the question. I could do this many times for each situation, always recommending the same alteration but in a problem-specific context. Does that mean I add weight to SO being a help-desk?
- I could vote to close as a dupe. For example, from sopython.com, "Is it more efficient to use a tuple/list/set for membership testing" is probably the closest match. But that has nothing to do with what the OP was asking, as a title, because they never knew the list lookup was the issue in the first place. The question content + dupe tag would probably also confuse me if it came up in my own Google searches for a problem I wasn't familiar with.
- I can comment an answer and leave it at that.
As it stands, I first did (4), got 6 upvotes – nobody has answered - and then did (3) which, from my experience, will age away in this situation (no support in over an hour). There's no other close vote and 45 views.
What is the suggested action here?