Python Forum
Lists: concatenate vs. extend vs. chain
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lists: concatenate vs. extend vs. chain
#7
Replacing using_chain with:

def using_chain():
    one = range(1, 1000000)
    two = range(1, 1000000)
    three = list(chain(one, two, one, two, one, two))
gets you:

Output:
repeat 10 using concatenation --> 1.96962308884 using extend --> 1.10849690437 using chain --> 1.07177019119
So it works if you are trying to get something to iterate over, but not if you want something you can manipulate as a list.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Lists: concatenate vs. extend vs. chain - by buran - Oct-09-2017, 08:44 AM
RE: Lists: concatenate vs. extend vs. chain - by ichabod801 - Oct-09-2017, 03:28 PM

Forum Jump:

User Panel Messages

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