mjschultz
Joined 16 years ago
Joined 16 years ago
* man page: http://manpages.ubuntu.com/manpages/trusty/man1/pollinate.1....
* Q&A style blog post: http://blog.dustinkirkland.com/2014/02/random-seeds-in-ubunt...
* A "why this is scary" blog post: https://tim.siosm.fr/blog/2014/04/25/why-not-ubuntu-14.04-lt...
In the context of this thread, brghts states that this is dangerous because if you compile with -DNDEBUG the assert is optimized away.
So if I copy that code with the assert statement, it will be optimized away and your code no longer performs the NULL check. This is bad.
As you mention, beginners tend to copy code off the Internet and cause bugs. If you recognize this and claim to be teaching people you should not use bad practices in your example code. Period.
If you don't want to muddy the waters with your custom debug macros, then you should still play it safe when checking return values the a beginner may simply copy and think is correct.
[1]: http://c.learncodethehardway.org/book/krcritique.html#code--...
> The problem is, as with every book with code ever in the universe, beginners will copy that code out and use it somewhere else and then the function is wrong.
Yet, if a beginner copied some of the code in this chapter they'd have the exact bug you are talking about here (using the NULL pointer returned from malloc()).
I think you should probably expand that into the safer checks (don't forget to free(line) if longest is NULL too!).
Other than that this seems like a great improvement!
The creation occurs in the --setup portion. The field accesses occur in the actual looping portion of the timeit code.
The timed portion is simply the field accesses.
My reading of the docs[1] has always led me to believe that it doesn't. For example, "It is possible to provide a setup statement that is executed only once at the beginning"
$ python -m timeit --setup "from collections import namedtuple; Point = namedtuple('Point', ['x', 'y']); p = Point(x=0, y=0)" "p.x + p.y"
1000000 loops, best of 3: 0.284 usec per loop
vs. $ python -m timeit --setup "p = {'x': 0, 'y': 0}" "p['x'] + p['y']"
10000000 loops, best of 3: 0.0737 usec per loop
Maybe the use isn't right because I agree with your belief that namedtuple is suppose to be more performant.But the article does cover more than just the incident, I found the whole thing fairly interesting.
Beyond the passing knowledge I have from growing up in Chicago-land around the time and the Wikipedia article on the subject, I thought it contextualized the FCC policies around the time of the incident and how the hack worked (from a high level). It also pointed out other signal intrusions from the same period and the FCC/FBI's methods to track down the perpetrators.
[1]: http://en.wikipedia.org/wiki/Max_Headroom_broadcast_signal_i...
http://www.beyond-syntax.com/