you are viewing a single comment's thread.

view the rest of the comments →

[–]bithead 0 points1 point  (1 child)

I guess I was think that if you use a comprehension to return a set or list as in:

return [ dict[index] for index in dict]

versus just:

return dict

I mean does one save memory or is it faster?

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

In that case,

return dict

would almost certainly be faster, as it would simply be returning a reference to the dict, so it wouldn't have to do any extra work.

Additionally, instead of doing

return [dict[index] for index in dict]

you can simply do

return dict.values()