Tag Info

New answers tagged

0

I'd suggest experiments. Logging will find bottlenecks. You can then try an alternative implementation on some machines, or even on all machines with a certain probability, or for a limited time period. Then compare the logs again to check for improvements. It's the same theory-experiment-measure cycle you're used to, but more expensive to set up - since ...


11

Actually its tough, but I am sure in lots of comparable situations it is primarily an organizational problem. The only viable approach is probably a mixture of combined measures, not just "one silver bullet". Some things you can try: logging: as I wrote already in a comment, excessive time and resource logging (which is a kind of profiling) can help you to ...


6

If you can't reproduce the live environment, the uncomfortable reality is that whatever you do, it won't have been sufficiently tested. So, what can you do? Well, whatever has to scale, be it a process, server cluster or database volume should be tested with the zero, one, infinity rule in mind to tease out where the potential bottlenecks/limitations are ...


0

Bit manipulation in Python is possible (if you mean the standard bit operations like AND OR XOR etc.), but you cannot change arbitary memory by design. You can use Cython (http://cython.org/) however, which is a extended dialect of Python which compiles to C.


1

In general, it's easier for people to understand the conditional without the negation - it's one less thing to think about when deciphering the meaning of the condition. The performance difference will probably be negligible, and worrying about it is premature optimization. (Besides, if you're working in Python, this kind of micro-optimization is worthless; ...


0

Python optimizer is pretty stupid by design, but this is one case that the optimizer happens to be capable of detecting: >>> def a(): ... if foobar: ... pass ... >>> dis.dis(a) 2 0 LOAD_GLOBAL 0 (foobar) 3 POP_JUMP_IF_FALSE 9 3 6 JUMP_FORWARD 0 (to 9) ...


7

There is 0 difference. However, there are some guidelines about what you put in the if and what - in the else. One is that you should try to put a "positive" result in the if. Many languages have shorter negation than " not " (Java has "!" that shouldn't have whitespace around it), and it's easy to overlook them, especially if you're looking at a verbose ...


10

It is considered to be best practice to arrange the condition such that it is most probable to be entering your if clause. The <50% condition should be your else clause. In this instance, it depends on what you're expecting. If you expect to find the file, then you should use if os.path.isfile(file_name):. This reason stems back to optimization of ...


3

Another answer gave an excellent overview over how you'd nicely encapsulate the row-oriented storage and give a better view. But since you also ask about performance, let me address that: SoA layout is not a silver bullet. It's a pretty good default (for cache usage; not so much for ease of implementation in most languages), but it's not all there is, not ...


1

What you have described is an implementation problem. OO design is expressly not concerned with implementations. You can encapsulate your column-oriented Ball container behind an interface that exposes a row- or column-oriented view. You could implement a Ball object with methods like volume and move, which merely modify the respective values in the ...


3

Short answer: you are fully correct, and articles like this one are completely missing this point. The full answer is: the "Structure-Of-Arrays" approach of your examples can have performance advantages for some kind of operations ("column operations"), and "Arrays-of-Structs" for other kind of operations ("row operations", like the ones you mentioned ...


0

I was after the same thing a came to the conclusion that is it permutations that I wanted and this "algorithm to generate permutations explained" did what I wanted. The example is in Ruby but it is quite easy to understand (and quite simple). Edit: From the mentioned website above: First things first, the basics: Permutations are how many times a set ...



Top 50 recent answers are included