14

I'll limit this question to a specific example that I have seen multiple times on the 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:

  1. 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 ` 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.
  2. 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?
  3. 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.
  4. 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?

13
  • 7
    1) Reduce the examples to MCVE's, 2) remove the background nonsense if it is irrelevant to the problem, 3) pick a title with good google-juice, 4) profit.
    – user4639281
    Commented Jan 19, 2018 at 0:42
  • @TinyGiant The MCVE exposes the issue. What then? That falls into point (1) of my question.
    – roganjosh
    Commented Jan 19, 2018 at 0:45
  • 3
    Performance questions have never been off-topic for Stack Overflow so long as they are reasonably scoped and well-defined. If the NumPy community is erroneously migrating questions then they should stop doing that.
    – user4639281
    Commented Jan 19, 2018 at 0:48
  • 2
    I read your point 1 wrong, I don't really get the point you're trying to make there I guess.
    – user4639281
    Commented Jan 19, 2018 at 0:54
  • @TinyGiant NumPy is a Python library that basically vectorizes calculations and pushes them into C/C++. If you ask a question about how to speed up a NumPy calc. then you will be upvoted because the aim is absolute speed. But it still carried the Python tag and if you ask a pure Python question, the attitude is a bit (generalising) along the lines of "it's a scripting language, it's not meant to be fast".
    – roganjosh
    Commented Jan 19, 2018 at 1:00
  • @TinyGiant I want to make it clear that I'm not complaining. The issue is that python is not known for speed, but has many libraries that are used for complex calculations and machine learning etc that basically push that all down to C/C++ and are used for speed. They all live in the same ecosystem though, which probably relies on pure python to integrate into the wider system. But this is going a bit off-topic from my question.
    – roganjosh
    Commented Jan 19, 2018 at 1:09
  • I have run into this in the Java tag as well (e.g. questions about control flow with polymorphism). People basically wrap a trivial/generic problem in an arbitrary level of specific complexity. That makes the question hard to close as a dupe, but also very unlikely to help somebody else in the future. Maybe a canonical "How do I solve this problem?" might help? So in this case: "How do I find performance bottlenecks in my python code". Commented Jan 19, 2018 at 11:42
  • 1
    I disagree with your characterization, even in general terms, that Python users and the Python community at large don't care about speed. There are plenty of questions and good-faith answers regarding efficiency and performance within pure Python on Stack Overflow and elsewhere on the Internet.
    – John Y
    Commented Jan 19, 2018 at 14:15
  • @JohnY Of course, you are correct. Reading back I missed my own point through tiredness I guess. A better way to state would be - if it's pure python then in general it could be considered unsuitable for SO because the code gives the correct output and running too slow wouldn't be a decent enough reason to ask for an answer. However, a subset of Python that includes pandas/numpy etc. would be highly welcomed by those communities because the attitude to that type of question is fundamentally different. The python tag is very active; 45 views and no answers suggests I'm not alone being unsure
    – roganjosh
    Commented Jan 19, 2018 at 15:46
  • @JohnY ran out of characters - 45 views and no answer to say: "Change your list to a set."
    – roganjosh
    Commented Jan 19, 2018 at 15:49
  • Under JavaScript tag lots of people has an issue to understand, async code, callbacks etc... It is always the same problem, in totally different context. Redirecting these users to another "similar" question would not help them. Personally I always try to leave a comment to show them a good direction, or if i have time fix there code and post as an answer.
    – Peter
    Commented Jan 19, 2018 at 18:50
  • @Peter That is the same as option (4) in my question, and it leaves an open-ended question just floating about. Adding a comment does not give a definitive end to a question, which is why I'm asking in the first place.
    – roganjosh
    Commented Jan 19, 2018 at 19:57
  • @roganjosh I just wrote down how I am dealing with this. I think leaving an answer in comments is ok, maybe later somebody gonna come, and write a more detailed answer about the fundamental problem what the user has. Or you can do this
    – Peter
    Commented Jan 19, 2018 at 20:14

2 Answers 2

7

In the first place, you should insist on such questions providing an MCVE. Comment to that effect to the OP, and if they do not cut down their code to an MCVE within a reasonable time then VTC as off-topic: no MCVE. Remember that the exercise of creating an MCVE is not just a hoop to jump through -- is useful to the OP.

Once there is an MCVE, if the OP has not already trimmed their prose then do it for them. All of the stuff that is specific to their project, motivations, programming philosophy, political aspirations, etc. ought to go. Do consider whether their title can be improved, too, as this often gets overlooked.

At this point, you (presumably) have a decent SO question. The original, as you describe it, was not one, and probably should not have been answered in that form. NOW, though, you can evaluate how to handle the question. Possibly it warrants its own answer, but more likely it warrants closure as a dupe. Perhaps it is appropriate to add a comment explaining why it is a dupe, but if the dupe target is a good one then it may not require one.

If you have recognized a common theme running through many questions, but there is no dupe target you are satisfied with, then you can always create one. Pose the question in appropriate generic terms. Note in it that you are creating it as a canonical question for use as a dupe target. Write a self answer. When sufficient time has passed, accept your self-answer, or even an answer from someone else if there's one you like better. Make both question and answer (if yours) community wikis. Close other questions as dupes of your new canonical one.

16
  • My question is a bit of a moving target because it's a situation that keeps cropping up again in different forms. A deliberately extreme case: "SQL query taking too long" as a question title. When you look at an MCVE you realise it has nothing to do with the query but how they process the query results. There can be no canonical answer to that question title... the OP mis-attributed the issue and there's a basic solution, which has nothing to do with their question title.
    – roganjosh
    Commented Jan 19, 2018 at 19:40
  • 1
    @roganjosh so you would edit it to clarify the problem, and remove anything that is not relevant to the problem, then edit the title to what it should be.
    – user4639281
    Commented Jan 19, 2018 at 20:03
  • @TinyGiant I'd see that as a pretty substantial change. I could just edit that question into a dupe of my choosing. Is that kind of edit acceptable?
    – roganjosh
    Commented Jan 19, 2018 at 20:06
  • @TinyGiant I'm not clear on this here. I have edited question titles to make them more appropriate to the issue the issue the OP is facing. But in my extreme example, I'd fundamentally change the whole question to fit what the actual problem is (in my mind). I'm not sure I'm ok with that; I don't know where the line sits on edits like that. Is there a meta post for this?
    – roganjosh
    Commented Jan 19, 2018 at 20:12
  • @roganjosh If the product of the question after it is edited to be clarified would be the same question as the dupe target, then it's a duplicate. Close it as such and move on.
    – user4639281
    Commented Jan 19, 2018 at 20:14
  • 1
    @roganjosh as per changing the question (if it is not a dupe), you aren't actually changing the question at all, you're just clarifying the actual question. I have performed many a "chainsaw" edit (edits which replace most or all of the original content of the post with clarified content). It's not so much how much of the original words and code remain, but whether or not the intent of the question (not the OP mind you) is the same.
    – user4639281
    Commented Jan 19, 2018 at 20:17
  • @roganjosh, a satisfactory MCVE having been provided by the OP, I'm having trouble imagining how you could make an edit that retains the MCVE and is consistent with it, yet fundamentally changes the nature of the question. Commented Jan 19, 2018 at 20:18
  • The pair of you are absolutely correct.Thank you, this closes the issue in my mind.
    – roganjosh
    Commented Jan 19, 2018 at 20:24
  • @JohnBollinger If a question is filled with tons of code that's irrelevant to the problem, particularly when its to the point that it's apparently obscuring the issue to most readers, then they don't have an MCVE, because their example isn't minimal. People always seem to forget that one when referring to MCVE...
    – Servy
    Commented Jan 19, 2018 at 22:11
  • 1
    Yes, @Servy. That's why the very first point in this answer is to "insist on such questions providing an MCVE." My commentary here is predicated on this procedure in fact being followed. Commented Jan 19, 2018 at 22:14
  • @JohnBollinger I was referring to just that comment. Saying, " a satisfactory MCVE having been provided by the OP [...]" The whole reason for the edit is to remove a whole bunch of irrelevant code/information obscuring the problem. The existence of that content means that, at least before the edit, there isn't an MCVE.
    – Servy
    Commented Jan 19, 2018 at 22:19
  • @Servy there's not tonnes of irrelevant code. I'd have voted to close if that was the case and never asked this question.
    – roganjosh
    Commented Jan 19, 2018 at 22:19
  • 1
    @Servy, I'm not sure what the disconnect here is. If the question indeed does not contain an MCVE, as I agree may be the case in a question such as you describe, then this answer says the first thing to do is insist that the OP provide one. Then, after the OP has done so, the conclusion in my comment follows. Commented Jan 19, 2018 at 22:25
  • @Servy my very first comment on this post possibly illustrates my point better. You're active on Python, you have surely seen this kind of situation.
    – roganjosh
    Commented Jan 19, 2018 at 22:25
  • JohnBollinger actually, your last comment to me, combined with @TinyGiant 's, made me look at MCVEs differently. I could easily reproduce the issue in the OP's question.
    – roganjosh
    Commented Jan 19, 2018 at 22:33
3

I think you should answer such questions, for the same reasons you allude to in the question.

As far as articulating a longer rationale — first, given the following:

  • if a question hasn’t gotten a bunch of downvotes (and doesn’t appear likely to you that it will)

  • if as somebody with domain knowledge about it you don’t think it’s clearly a duplicate

  • if it hasn’t gotten flagged by anybody else as a duplicate

…then it seems like the question’s gonna remain there, unclosed and maybe unanswered or not well-answered. So as far as adding weight to SO: leaving the question hanging around unanswered when you know a good answer for it — that may be the choice more likely to add unneeded weight.

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.

I think the “problem-specific context” part there is important. Obviously every problem has a specific context — especially to the user who is having the problem.

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.

Right. And you may have already run into a case where if you flag such question as a duplicate of some other that has a different context, the user who asked the question you’re flagging as duplicated sometimes responds to point out that what you’re asserting their question is an “exact duplicate” of (as the language of the duplicate message ends up indicating) actually has a very different context than the problem the user is asking about.

The particular user of course may sometimes be wrong or may lack enough domain knowledge to understand how the two questions relate — or even how any answer for the other question relates. But if that particular user doesn’t clearly see the application of the other question+answer to the context of their problem, then it may well be that other users who come along later from searches with the same or similar problem might also not see how the other question+answer relates.

So for that reason, it can be quite valuable to have a good answer right there at point of use with that question which has that particular context. That way, future users coming in also can more clearly and quickly find the solution too.

12
  • 1
    This is a very objective answer and I'm inclined to agree. I just hate the idea of multiple answers floating about saying "use a set" for a common problem that people don't know they face. I'll wait to see the community vote on this :)
    – roganjosh
    Commented Jan 19, 2018 at 1:13
  • 1
    @roganjosh Sure, I hear what you’re saying. Maybe this is a case where a new FAQ entry at sopython.com/canon or wherever would be useful. It could say something like, “When you run into a problem where you’re trying to do [something] and you notice [whatever is happening], the underlying issue is actually list lookup — even though that might not be obvious to you — and the solution is [the other FAQ entry about list lookup].”
    – sideshowbarker Mod
    Commented Jan 19, 2018 at 1:28
  • 1
    @roganjosh Anyway, seems like in this scenario there’s still gonna be multiple questions around, and you can’t avoid/fix that. I mean, even if the questions all get marked as duplicates by somebody (rightly or wrongly), they’re all still gonna remain a pages in SO — getting indexed by search engines, etc. Given that, I guess maybe you should consider what user experience you want others coming to those questions in the future to have when they land on those pages. To me at least, if it doesn’t cost you a lot of time to post a useful answer specific to the question’s context, that’s a win.
    – sideshowbarker Mod
    Commented Jan 19, 2018 at 1:35
  • 1
    @sideshowbarker But the answer to why there is a problem is the linked duplicate. So the question should not be answered. (Your answer's 2nd bullet "you don’t think it’s clearly a duplicate" contradicts the question, because the answer to the problem is the linked duplicate.)
    – philipxy
    Commented Jan 19, 2018 at 9:21
  • @philpxy huh? the OP says the case is that there's no clear dupe: "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"
    – sideshowbarker Mod
    Commented Jan 19, 2018 at 10:24
  • @sideshowbarker No, we don't want a whole bunch of duplicate questions all getting the same exact answer posted to all of them over and over. That's awful advice. If a bunch of people are all asking the same question then we do want them all closed as duplicates.
    – Servy
    Commented Jan 19, 2018 at 15:52
  • @sideshowbarker The question, as asked, just isn't an appropriate question. [giant code dump] followed by, "how do I make this better" just isn't appropriate on SO.. Among other things, that will never be useful to anyone If someone has some code and they're able to identify a particular performance problem, narrowing down their code set to a particular, reasonably small, snippet that they've identified a problem with, like say that searching a given collection is unreasonably lengthy, then that can be an on topic question, and that would be a duplicate.
    – Servy
    Commented Jan 19, 2018 at 15:55
  • 1
    @Servy I agree with your conclusion about the scenario you describe. But what you describe is a different scenario from what the OP described. You write, If a bunch of people are all asking the same question then we do want them all closed as duplicates, but as formulated by the OP, the problem isn’t “a bunch of people are all asking the same question” — instead it’s a variety of questions with different contexts that aren’t obviously related to the questioners nor will be to the people coming across them in searches later. My answer was based on that premise.
    – sideshowbarker Mod
    Commented Jan 19, 2018 at 22:04
  • @sideshowbarker The fact that the questions have obscured the fact that they're all asking the same thing by including a whole bunch of irrelevant information and not doing a good job of identifying their problem makes them bad questions, but it doesn't make them different questions. The fact that none of these questions are going to be useful to any future reader ever doesn't make them not duplicates, it just makes them bad quesitons, and is all the more reason to not waste people's time trying to give the same answer to every single one instead of closing them as duplicates.
    – Servy
    Commented Jan 19, 2018 at 22:09
  • @Servy As far as “The fact that none of these questions are going to be useful to any future reader”, I don’t see where the OP states that “fact” in the question. You seem to be imagining a scenario different from what the OP has actually described — a worse-case strawman that completely lacks any kind of nuance or subtlety. In the case you seem to have mind, I strongly agree with you it’d be awful advice to suggest answering. That’s why I’m not giving that advice. Instead I gave advice based on the scenario the OP described, and not instead on the different one you describe in your comments
    – sideshowbarker Mod
    Commented Jan 19, 2018 at 22:15
  • @sideshowbarker How is, "here's a bunch of code, it's slow, how can it be faster" going to be helpful to anyone else? Are you expecting other people to have that same code, and also need it to be faster? If so, how are you expecting those people to find this question?
    – Servy
    Commented Jan 19, 2018 at 22:17
  • @sideshowbarker The title is not the question. "one change probably fixes the issue"
    – philipxy
    Commented Jan 20, 2018 at 2:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .