Opened 4 years ago

Closed 4 years ago

#31556 closed Cleanup/optimization (wontfix)

Remove useless (and inefficient) listcomp in the poll tutorial

Reported by: Alexandre Poitevin Owned by: nobody
Component: Documentation Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

output = ', '.join([q.question_text for q in latest_question_list])

This is not needed since a long time.

Change History (3)

comment:1 by Sergey Fedoseev, 4 years ago

Could you elaborate on its uselessness?

comment:2 by Simon Charette, 4 years ago

Triage Stage: UnreviewedAccepted

The materialization of the list is not required as str.join accepts an Iterator[str].

', '.join(q.question_text for q in latest_question_list)

comment:3 by Nick Pope, 4 years ago

Resolution: wontfix
Status: newclosed

This has come up before and was rejected… A list comprehension is preferable here as str.join() converts to list internally anyway. It is better performance to provide a list up front.

Note: See TracTickets for help on using tickets.
Back to Top