Python Interview Questions

Ian Kelly ian.g.kelly at gmail.com
Wed Sep 5 11:22:58 EDT 2012


On Wed, Sep 5, 2012 at 8:34 AM, Chris Angelico <rosuav at gmail.com> wrote:
> I wouldn't go that far. The 'name' parameter, I would expect, would be
> a constant.

The 'item' parameter, though, is probably not a constant, and it's
interpolated just the same.

> However, this strikes me as encouraging some really
> inefficient code, like iterating over all the rows in a table with N+1
> queries (one to get the length, then a separate query for each row).
> Plus, use of limit without order by is not guaranteed (although since
> this is specific to MySQL, it's unlikely you'll run into trouble - but
> PostgreSQL, with its MVCC storage system, frequently reorders rows in
> a table).

The lack of an ORDER BY is the least of the problems with that SQL.
He's also using LIMIT without OFFSET, so the only thing that the
'item' argument changes is how many rows are returned (all but one of
which are ignored), not which one is actually fetched.

It's a bit sad that these are touted as answers to interview
questions.  I wouldn't hire anybody who gave answers like these.



More information about the Python-list mailing list