Apr
10
comment python script hangs when calling cursor.fetchall() with large data set
Sounds like you already know of a way to get the result you want. Why don't you just do that? Clearly, trying to load a large amount of data all at once is hard. Why do you insist on doing that when you already have a solution that a) works b) does not load such a large amount of data at once?
Apr
10
revised Read a line store it in a variable and then read another line and come back to the first line. Python 2
Formatting was messed up. I think I've gotten the intended formatting, but I'm not sure. Please, take a careful look.
Apr
10
asked Does Erlang have methods?
Apr
2
comment why would load_module be called if the module is already in sys.modules?
@martineau: that sentence does not explain. Read my question: the Python import system could (but does not) detect that such behavior is required and skip calling load_module entirely.
Apr
2
comment What is an asterism compared to a constellation?
These answers are pretty unsatisfying: OK, so constellations are these patches of sky decided upon by some group of people. Presumably, they had some rationale in picking the current set of patches, and not some other set. Is it just based on Greek tradition? I think that's the sort of answer that people are generally looking for.
Apr
1
asked why would load_module be called if the module is already in sys.modules?
Apr
1
comment How should one use std::optional?
@TimothyShields Thanks. That makes sense. I would still argue for unique_ptr being the default choice though. My rationale would be that trading a little performance for consistency is worth it, and like you said, it's an implementation detail (or at least, I would consider it to be). My suggested policy would be "choose unique_ptr, unless you measure a significant performance improvement from going with optional", at least in application code. Maybe this doesn't make sense for libraries, since you can't tell what the overall perf impact is going to be.
Mar
10
comment How should one use std::optional?
I guess my previous comment assumes the type is not movable and expensive to copy. Unless you're the type is from the std lib, I think in 2015, that's a pretty fair assumption to make. Maybe 10 years from now, everything will be movable (I hope so), but for now, I'm not sure I see any great advantage of using optional instead of unique_ptr.
Mar
10
comment How should one use std::optional?
Why not use std::unique_ptr instead? Sure, you need an object on the heap. So what? If the object is large, and you are trying to pass or return it, that's probably a good thing, because that will make it cheaper to pass and/or return.
Mar
6
revised Difference between equal to and exactly equal to term comparison operators
Looks like there was a typo in the question that has since been corrected.
Mar
4
awarded Good Answer
Mar
2
comment In Erlang how is using registered processes different from global variables in a traditional language?
The advantage of HonestToGoodnessPid or ServiceFactory is that your API does not lie about what it relies on. With register, a thing that you rely on is obfuscated, making it difficult to test. In order to test, you must know what registered processes must exist. Ideally, a function's behavior depends only on its arguments. Of course, some functions also receive; in those cases, it should be determined by a second thing: messages that it listens for and receives. register provides a third hidden (and therefore unwelcome) side channel by behavior can be affected.
Mar
2
comment In Erlang how is using registered processes different from global variables in a traditional language?
re locating long-running services: Pretty sure the same thing can be done without resorting register. One problem with register is that everybody and their mama now knows about processes in the registry. Another is that does_not_exist ! foo can blow up in your face. HonestToGoodnessPid ! foo cannot, even if that process is defunct, non-responsive, or whatever. If you're going to get around that by doing whereis(does_not_exist), then you might as well pass in ServiceFactory, and call it instead of whereis.
Mar
2
revised In Erlang how is using registered processes different from global variables in a traditional language?
"such" appears to be errant and extraneous; added 3 characters in body
Mar
2
comment In Erlang how is using registered processes different from global variables in a traditional language?
I had the exact same question. This does not seem at all unreasonable. I'm also new to Erlang, but it very much seems to me that register would have the same problems as global variables.
Mar
2
revised Can you use a list (or other collection) to specify what messages to receive in Erlang?
edited title
Mar
2
comment Can you use a list (or other collection) to specify what messages to receive in Erlang?
Just because you cannot imagine how this could be useful does not mean that it's crazy. The messages are not unexpected; the set of expected messages is specified dynamically in a list, rather than statically in code.
Mar
1
reviewed Approve suggested edit on What is the difference between node.js and io.js?
Mar
1
comment Can you use a list (or other collection) to specify what messages to receive in Erlang?
I don't think you understand the question: the list is not static. Imagine you are given an ARBITRARY list of the form given in the question (that's why there's an Etc() there), and the same code must be able to handle such a list. Your second suggestion ignores the requirement that non-matching messages do not get removed from the mailbox, or that any removed message needs to be put back in the same position.
Mar
1
comment Is there a way to tell whether a function has a matching clause without calling it in Erlang?
nit: callee can fool you by returning a value of the same form though. Seems better to use try + catch, as suggested in other answer. But still, thank you!
1 2 3 4 5