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

On performance, this from wiki.python.org:
Quote:Python supports a couple of looping constructs. The for statement is most commonly used. It loops over the elements of a sequence, assigning each to the loop variable. If the body of your loop is simple, the interpreter overhead of the for loop itself can be a substantial amount of the overhead. This is where the map function is handy. You can think of map as a for moved into C code. The only restriction is that the "loop body" of map must be a function call. Besides the syntactic benefit of list comprehensions, they are often as fast or faster than equivalent use of map

Larz60+
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,684 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