Python Forum
print a list strings is fast but printing the joined strings is slow
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print a list strings is fast but printing the joined strings is slow
#2
No idea why you get the result you do, but for me, printing b is about 5 times faster:
>>> timeit('print(a)', 'from __main__ import a', number=1)
(...)
4.1929473
>>> timeit('print(b)', 'from __main__ import b', number=1)
(...)
0.7649681999999984
Reply


Messages In This Thread
RE: print a list strings is fast but printing the joined strings is slow - by stranac - Aug-26-2019, 05:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Mapped Strings edualfaia 12 2,166 Sep-04-2023, 11:08 AM
Last Post: snippsat
Question bytes and strings Skaperen 0 777 Aug-28-2023, 02:58 AM
Last Post: Skaperen
  f-strings round float down too much Skaperen 5 2,626 Dec-29-2021, 08:37 PM
Last Post: Skaperen
  f-strings in a script to be made public Skaperen 2 2,158 Jan-03-2020, 06:03 PM
Last Post: Skaperen
  supporting both strings and bytes in functions Skaperen 0 1,439 Nov-28-2019, 03:17 PM
Last Post: Skaperen
  side effects in f-strings Skaperen 0 1,705 Sep-08-2019, 01:26 AM
Last Post: Skaperen
  trying to learn f-strings - puzzled by format() protocol Skaperen 7 3,763 Jul-26-2019, 08:40 PM
Last Post: Skaperen
  mixing bytes with strings Skaperen 3 2,444 May-29-2019, 02:30 AM
Last Post: heiner55
  to strings or to bytes, that is the question Skaperen 0 2,061 Jul-07-2018, 08:35 PM
Last Post: Skaperen
  mutable strings Skaperen 3 3,554 Dec-03-2017, 03:05 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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