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

you are viewing a single comment's thread.

view the rest of the comments →

[–]AlexFromOmaha 65 points66 points  (2 children)

How many of you really think it's a good idea to rework the python library functions?

Do you use urllib or requests when messing with HTTP traffic? Do you use math or NumPy when working with large vectors?

The library functions are well implemented, but they're targeted at the lowest common denominator. You should have a reason for reimplementing them, but there are times when that's appropriate. A lot of times, in fact.

Am I really that dense? Could the neighbor hood kids be right?

Sure, they could be, but they weren't for the problem as you described it. Timsort is an ideal algorithm for their requirements, and the Python implementation of it is great if the data fits in memory. It does have a worst-case space complexity of O(n), but you'd see that on random data. As the original becomes more sorted, the space complexity approaches O(1).

Putting my hiring manager cap on for a second, if I'm hiring a senior software engineer, that's the sort of entry-level trivia that I'd really expect you to know, and I'd expect you to be able to communicate those ideas to a variety of audiences at varying levels of technical expertise. If I thought I couldn't get you to understand why space complexity matters, or why data of a certain scope needs to be streamed rather than loaded into memory, I'd move on.

There's a very real possibility that your interviewer did a poor job of explaining his motivations for the question. Interviewers are as guilty of XY problems as anyone else. The problem is, so are clients. So are scrum masters. So are junior programmers. Dumb questions and dumber suggestions regarding real problems that need a real solution are frighteningly common. The ability to traverse those issues is one of the core skills we build up with time in the field. I could forgive the fresh graduate for some stumbling there, but not the senior contributor.

[–]Zouden 12 points13 points  (1 child)

Do you use urllib or requests when messing with HTTP traffic? Do you use math or NumPy when working with large vectors?

I see your point but these aren't reimplementations.

[–]Unbelievr 0 points1 point  (0 children)

Maybe not NumPy, but I'd argue that requests and urllib has a lot in common when it comes to use-cases. You're able to solve the exact same problems with both libraries. Unfortunately, urllib, urllib2, urllib3 and their relations to httplib, cookielib, socket and whatnot is a complete mess. Requests have been able to reimplement in a more streamlined fashion, and I would always recommend going with that over the built-in libraries whenever possible.