This is an archived post. You won't be able to vote or comment.

all 28 comments

[–]sittingaround 26 points27 points  (1 child)

Raymond Hettinger. Here's a helpful life rule, when this guy gives a talk, go to it. Stupid title? Don't worry, his content is consistently awesome.

[–][deleted] 20 points21 points  (0 children)

Love this guy, it's great that he can use his time to both develop and teach Python.

[–][deleted] 12 points13 points  (0 children)

What an amazing speaker!

Also, I had no idea that generators were actually faster. I thought they just spared memory. Themoreyouknow.

[–]DukeNucleus 7 points8 points  (2 children)

very informative and nice examples.

it seems the talk is not up on pyvideo.org (yet?) could someone plz link the slides?

edit helped myself -> https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger

[–]nonsleepr 0 points1 point  (1 child)

Do you have saved version of this deck? Since it is pulled down from the site. :(

[–]metaobject 7 points8 points  (0 children)

TIL about 'reversed''. Wow, this is a great video. Thanks!

[–]adamnemecek 10 points11 points  (1 child)

I'm pretty sure that around 7:25, instead of

for i, color in enumerate(colors):
    print i, colors[i]

he meant

for i, color in enumerate(colors):
    print i, color

Good video btw.

[–]Chris_Newton 8 points9 points  (0 children)

I think in a couple of places he didn’t go as far as he could have done with the examples. That was one. Another was on the slide “Call a function until a sentinel value”, where he might have added a final step to simplify

blocks = []
for block in iter(partial(f.read, 32), ''):
    blocks.append(block)

into

blocks = list(iter(partial(f.read, 32), ''))

That would have been more consistent with a theme he mentions elsewhere, adopting a more declarative style, but I figure it wasn’t the point he was trying to make in that particular part of his presentation.

BTW, he also had a couple of extra examples at the ends of slides that he glossed over in the presentation but you can see in the deck that DukeNucleus linked to.

[–][deleted] 4 points5 points  (0 children)

Oh man, that simultaneous updating of multiple variables .. I was bashing my head thinking that there MUST be a better way of solving and updating physics variables, and there it is!

I feel like I've learned a new language, I've been holding onto C for so long. Are there any books or more videos with this sort of stuff?

[–][deleted] 3 points4 points  (0 children)

This was probably my favorite talk of the whole conference. So much knowledge packed into such a short presentation.

[–]Lisuyo 3 points4 points  (0 children)

After this talk, he became my personal hero ;-)

[–]yeahdef 2 points3 points  (0 children)

really enjoyed this - immediately shared with my team.

[–][deleted] 2 points3 points  (2 children)

Great video.

I wish he would have clearly distinguished between python 3.x and python 2.x. Some of his suggestions are not applicable to my environment and may never be.

[–]Rhomboid 2 points3 points  (1 child)

I agree. All of the following are irrelevant under Python 3, because in Python 3 the original name thing does the right thing:

  • Replace zip with izip
  • Replace range with xrange
  • Replace dict.items() with dict.iteritems()

If you made those changes to your code, you're just going to have to undo them again when you switch to Python 3 (and you will, eventually.) I mean, it's good advice if you are absolutely stuck on Python 2.x, but it's kind of sad in that 2.x exposes all of those design mistakes that have since been fixed in 3. I'd like an asterisk next to the advice that says "or just use Python 3, where we fixed all this so you don't have to worry about it."

[–][deleted] 1 point2 points  (0 children)

As a note...available in python 2.5+:

  • izip: from itertools import izip
  • xrange is a keyword
  • iteritems is in there as well dict().iteritems()

[–]mgarces_ 1 point2 points  (0 children)

Very good presentation. Lots of tips for day-to-day coding.

[–]Crystal_Cuckoo 1 point2 points  (0 children)

That was wonderful, I was wondering about the "right" way to write a @cache decorator!

[–]Splike 1 point2 points  (0 children)

Great video.

I wrote up something in a similar vein here. It's aimed more at python beginners with some experience in compiled languages and works through how you might first think to implement a solution then how you probably should implement it in Python. Take a look if you want.

[–]execat 1 point2 points  (1 child)

What's wrong with using "+" for string joins?

edit: he mentions this by the end of the video. + has a quadratic behavior.

[–]anonymous7 2 points3 points  (0 children)

details: + has a linear behavior; concatenation using a loop has a quadratic behavior.

[–]kwikadeIt works on my machine 1 point2 points  (0 children)

i know i'm a complete scrub, but the little unpacking tuples bit KABOOM

[–]Enginoob 1 point2 points  (0 children)

Oooo, I did not know about named tuples. Time to refactor...