Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

The format of the article, and it's unwillingless to go to the point made me quit reading half way. Even in reader mode the flow of reading is interrupted every 2 lines by a large useless image or some snarky comment from the author.

Too bad, it's an interesting topic.


Author here. Would my raw talk script without any of the visual aids I put in the talk be better here?


Absolutely! I suspect it would also alleviate a couple of headscratchers like where you spelled out "underscore" when setting a breakpoint.


Looks like I missed a sed command or two. I usually write out "underscore" in the script so I read it literally during recording: https://i.imgur.com/j3RdHA5.png

I write out punctuation like underscore so that I know that is what I am literally saying to the camera. I usually edit that out. Apparently I missed out on that this time. Oops! Sorry. I'll put that on the checklist for next time (half considering making tests fail if I forget to do it).


Outstanding, highly readable work. Double props for the Jenna Fischer photo.

One suggestion might be putting hyperlinks in as either end notes or as anchor tags for those interested in chasing rabbits.


> the visual aids

Of all your pictures the actual useful ones are three:

Drawbacks of PAM

Lessons Learned

Credits

Presentation != blog post. Different formats. I could read that only after sticking the browser to the side of the screen with 25% width and reader mode. Reading your post on the desktop is like trying to watch a 10-minute episode interrupted for an ad every 10 seconds.

Perhaps you can split your 'visual aids' to 'essential' (liek those three I listed up there) and 'non-essential', which could be skipped in the blog post.


Yes, or just an option to hide the slides.


Here: https://gist.github.com/Xe/400756b7d93f40b0b7ec48c65b7d066d

I'll work on something more cohesive for the next talk. Sorry about this!


At least with this I can work out what your primary points are. The most important takeaway seems to be that OpenSSH sshd doesn't really use PAM unless you enable "ChallengeResponseAuth" config option, so if you want your custom PAM module to work with sshd, you need to turn that on.

Another important point you make is, on Ubuntu, you need to download the debug symbol packages for systems libraries if you want gdb to give you meaningful backtraces.

The suggestion of putting a breakpoint on dlsym also seems helpful.

This meme-laden presentation style, I seem totally incapable of consuming or producing it, and I don't really get it. I don't know if it is a generational thing or something.


Thanks, now I could read it entirely.


For reference, I liked your format. It was different and fun. Every highly technical conference would be infinitely more fun if all speakers were given an avatar like that haha. I especially loved the graphic with Anya pointing at Anya pointing at Anya :thumbsup: .

It was obvious you were going for an entertainment format rather than merely cramming as much information in as tight a space as possible (which is typical for 'conf talks). Hacker News geeks probably aren't the ideal judges for that sort of thing. As a member of this group most of us have forgotten what it means to "not be super busy" all the time and being "forced" to watch something highly technical slowed down into an entertainment-focused story telling format can feel wrong and a little frustrating. Just know that there's at least a few people out there that appreciated it :)


Is there a video of the presentation somewhere? That would be ideal! Thanks


The YouTube video is embedded in the page.

https://youtu.be/BleS-MHLn7s


d’oh! Thanks!


It's a presentation in blog form. The images are the slides from presentation, the text is what Xe says. Perhaps you don't like this style of presentation?

Excellent content.


On the other hand, I found the slides wildly entertaining. To each his own.


"attempt to reproduce" then. Because a lot of those studies cannot be reproduced, that's the point.


For me (windows, chrome or ff), it works only on the blue markers, but zooming on the map does not make it more details, and the switch to street view leaves a blank canvas.


* Conditions apply. Use the comment in the context of the HN bubble, and ignore that a huge part of the industry is still deploying wordpress on VPS, using excel spreadsheets for database and gmail for bug tracking.


The GP was talking about data centres. I’ve worked in data centres and thus replied with the same context as the GP was discussing.

Also people deploying Wordpress on a VPS and using Excel are categorically NOT doing any form of distributed computing, which is what this discussion is about. So it’s correct to discount those contexts.

What I’m noticing here is a lot of people are confused about the terms “distributed” and “data centre”.


Itertools is your friend:

    from itertools import product

    for x, y in product(a1, a2):
        if test(y):
            break
Not only you get the behavior you want, but you get an easier to read code with one less level of indentation. Bonus, you can now use "else" (which most people don't know can be used with "for" and not just "if").

Why introduce a new syntax when a library does the job? A new syntax is a huge bar to pass for a language, and nested loops are rare.

Itertools is a gem, and any python dev will benefit greatly from mastering it.


It is markedly less efficient since you will test y every time for each x, as opposed to once. O(1) vs O(n)


Specifically the original double loop example also has this behavior and complexity.

If the loops were written as

  for y in a2:
    if cond:
      break
    for x in a1:
      # something
then they would have O(|a2|) complexity instead of O(|a1||a2|), but then we also don't need break break


The first loop would catch it, it would not reach the next. But you can indeed use any exeption. However, itertools.product does a better job.


Python has had itertools.product for ages for this use case.


product only covers independent nested iterations, some of them have dependencies.

But for those you've got iterools.concat, or generator comprehensions.


EDIT: made a mistake, see my next comment bellow. I won't update this comment so that other readers can see the code for the 2 use cases.

Python has itertools.product and unpacking for this case:

    from itertools import product

    space = product(enumerate(table.rows), enumerate(row))
    for (r, row), (c, cell) in space:
        if search_query.matches(cell.value):
            logger.info("Found cell: (%s,%s)", r, c)
            return (r, c)
Note that we don't need the "found" variable neither to get the same beheavior. We can also use break + else, but in this case, the return is cleaner since that's the default value for python functions. Additionnally, the logger should do the interpolation, not format().

I think the Python team is having to do the difficult job of filtering new feature, and it makes sense they don't introduce it in this case. We already have all the facilities in the language to deal with most nested loop cases, and those are rare cases anyway.


Not in this case. 'row' is an item in the 'table.rows' iterable.


Right, I misread the code, my bad.

For this case, one should use a nested comprehension:

    space = ((r, c, cell) for r, row in enumerate(table.rows) for c, cell in enumerate(row))
    for (r, c, cell) in space:
        if search_query.matches(cell.value):
            logger.info("Found cell: (%s,%s)", r, c)
            return (r, c)
Or see masklinn comment if you don't need the logger.

In all languages, you separate code for preparing your input and code for processing it. In python, it's also a good idea to do that at the loop level:

- prepare your stream of data so that it's normalized using itertools, generators, a function, a numpy array, etc

- do a single loop pass for your processing

This way you will you obtain a single iterable, and will be able to get the most out of the language tooling:

- you can pass it to map/filter, itertools or another comprehension

- you can convert to a list, a tuble, a Counter, etc. And slice it

- you can use "else" in the loop, which is an underused construct, but very useful when you need break

- you can use advanced unpacking

- you can call iter() and/or next(). This is what masklinn does in his example.

The point being, nested loops are rare enough, and we have tool to deal with them in an idiomatic way in Python, and not adding new syntax for a rare case that usually has a good solution makes sense to me.


At that point you might as well make the entire thing into a gencomp inside a `next()` call, the explicit for loop is redundant.


Yes, if you don't need the logger, it is indeed cleaner.


In that case a flatmap does the job fine[0]. In fact you don't even need a flatmap:

    found = next((
        (r, c)
        for r, row in enumerate(table.rows):
        for c, cell in enumerate(row):
        if search_query.matches(cell.value)
    ), None)
Or just return at the location where you found a match. That way you can also provide a better error message in the failure case.

[0] well map + itertools.concat, IIRC the stdlib doesn't have a flatmap per-se, though more_itertools probably does.


Nassim Taleb famously destroys those lines of reasoning in his books: game theory is unpractical for most people, because it almost always ignore variables that don't exist in a lab but are crucial IRL.

Comments have been explaining which ones already apply to this article, I'm not going to repeat them.

But there is an another example from Taleb that always makes me smile:

- If the other player tosses a coin and gets 9 tail in a row, what are the chances of getting tail on the next toss?

- 50%!

- No, 100%. The other player is cheating.


Indeed, but:

- when declaring routing in code, it's harder to shoot yourself in the foot. So many php sites expose what they should not, and .httaccess is rarely crafted correctly

- renaming files don't change your website

- coding locally doesn't require apache if your tooling don't need it for routing. No need for stuff like EasyPhp

- python dev servers automatically reload for you on changes anyway

- declaring routes and parsing them at one place to get url id and slug is less duplication

- declaring url yourself mean you can use the language typing system for their checking too (see fastapi)

- I rarely need an entire file for one route endpoint, making 10 files for 10 enpoints that could fit in one is overkill

- wsgi servers like gunicorn will hapilly reload the workers when it receives SIGHUP in prod. No need to restart the master process manually.

- restarting a process every time mean you can't benefit much from nice python features like lru_cache, process/thread pools, connection pools, etc

- python is slow to start, cgi takes a toll

- it's easier to control the number of max workers that run an any given time

Honestly, even when coding in PHP I will use phpfpm (which is one long running process like python) and frameworks like laravel (in which you declare your routing).

I understand the desire for simplicity, and the one-file/one-route declaration is easy to get into. But if I want simple, I do a static website with a bit of client side JS, not need for a backend.

When I do need a backend, I much prefer long running workers and explicit route declaration.


None of the points you mention are an argument against CGI for me. But it is mostly a matter of taste.

There is one point I would like to address though:

"python is slow to start"

Python is slow. Dead slow. But not to start:

    echo 'print(1)' > test.py; time for i in {1..100}; do python3 test.py > /dev/null; done
Gives me 1.6s

    echo '<?php echo(1);' > test.php; time for i in {1..100}; do php test.php > /dev/null; done
Gives me 1.9s


I'd say they are both slow. Try Perl, Tcl, Lua or some other interpreted language that starts fast, and you'll likely see something like 200-300ms for the equivalent commands to above.


As in so many measurement/benchmarking situations, "compared to what?" is indeed The Big Question.

For example, you can also compare to a C program not doing much, overhead-wise:

    /usr/bin/time bash -c 'for i in {1..100}; do /bin/true; done'
which gives me like 70 ms for all 100 or 0.7ms per each startup, with also some adjustment to start-up the bash driver shell itself.

Even that 700 microseconds is a high number, from glibc & dynamic linking mostly. If you

    echo 'int main(int ac,char**av){return 0;}' > /tmp/true.c
    musl-gcc -static -O2 /tmp/true.c -o /tmp/true
and repeat, you see 380 microseconds per each.

In benchmarking scenarios requiring more elaboration than makes sense in an HN comment, I see times as low as 140 microsec per run on that same machine/OS. In fact, as you push things to low overhead extremes, you can easily see the impact of how much environment variable data is in play (`env -i` vs. not).

It is true that Python start-up time is not that bad compared to a "mean diameter of the Internet in milliseconds" which is probably the relevant time scale for CGIs, but it's probably not so small as to be truly negligible, esp. once imports are happening.

Also, Python3 remains quite a bit slower (1.7X slower on that same machine) to start-up than Python2 even after more than a decade of promises to claw back start-up performance.

Meanwhile, on the other side of the comparison, starting up a Julia REPL seems to take quite a bit longer than the Python 16 ms..Like 340ms or 20X longer.

So, the overarching point of this overlong post is just a follow-up/supporting of @tyingq's "compared to what?" with a little more detail.


    echo 'print 1' > test.perl; time for i in {1..100}; do perl test.perl > /dev/null; done
Gives me 0.25s

Clearly the winner!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: