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
#2
As I know, R. Hettinger is Python core developer so he knows the internal C code of each of those methods. Perhaps his tweet is based on that.
On what hardware, OS do you run this code?

Misstype on line 34: print('using concatenation --> {}'.format(timeit.timeit("using_concatination", number=repeat, setup="from __main__ import using_concatenation")))

Here is my result on Arch linux:
repeat 1000000
using concatenation --> 0.010602696005662438
using extend --> 0.010252392006805167
using chain --> 0.009878639997623395

But this was the first try. Most of the time I get something like this:
repeat 1000000
using concatenation --> 0.010324251998099498
using extend --> 0.01023155700386269
using chain --> 0.010108978000062052
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
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 wavic - Oct-09-2017, 09:24 AM

Forum Jump:

User Panel Messages

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