Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List Comprehensions
#1
Hello,

I've recently discovered List Comprehensions - which, for the project I am working on, are awesome.
I'm having to create lists based on other content that gets  'filtered' with for loops / if statements.

A lot of people mention List Comprehensions being 'easier to read'.
Honestly, I think the feature is cool, but I much prefer the readability of the old fashioned way - actually nesting this stuff inside of their for loops / if statements.
For some reason, having everything broken down like that is just easier for me to follow and understand what the program is doing.

So - 
A) Though both yield the same result, is one way faster than the other?
If in fact they take the same amount of time to process, then what is the benefit of doing the comprehension - just the 'readability'?

B) In the 'real world' of using Python - is it frowned upon to build lists not using the list comprehension feature (assuming execution time is the same)?

At first glance, this seems like a Personal Preference vs Actual Performance battle.
Reply


Messages In This Thread
List Comprehensions - by ATXpython - Oct-01-2016, 06:07 PM
RE: List Comprehensions - by ichabod801 - Oct-01-2016, 06:30 PM
RE: List Comprehensions - by snippsat - Oct-01-2016, 06:38 PM
RE: List Comprehensions - by Ofnuts - Oct-01-2016, 09:20 PM
RE: List Comprehensions - by Larz60+ - Oct-01-2016, 09:44 PM
RE: List Comprehensions - by Skaperen - Oct-02-2016, 01:02 AM
RE: List Comprehensions - by metulburr - Oct-02-2016, 01:09 AM
RE: List Comprehensions - by snippsat - Oct-02-2016, 08:56 AM
RE: List Comprehensions - by Yoriz - Oct-02-2016, 11:39 AM
RE: List Comprehensions - by Larz60+ - Oct-02-2016, 11:59 AM
RE: List Comprehensions - by Yoriz - Oct-02-2016, 12:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  abusing comprehensions for one line loops Skaperen 6 2,553 Dec-16-2019, 11:22 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020