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
#6
alright! it is working now and I need a clarity

>>> a= 'okay'
for i in range(4): timeit('print(a)','from __main__ import a',number=4)
Output:
>>> for i in range(4): timeit('print(a)','from __main__ import a',number=4) ... okay okay okay okay 0.0035411143718420135 okay okay okay okay 0.0012378038995848328 okay okay okay okay 0.0006817251627353471 okay okay okay okay 0.001336081797035149 >>>
So, here it is displaying timer after printing okay for 4 times. It that a cumulative timer to print all the 4 okies or how it working??. Please explain..! Thanks in advance!
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Mapped Strings edualfaia 12 2,384 Sep-04-2023, 11:08 AM
Last Post: snippsat
Question bytes and strings Skaperen 0 831 Aug-28-2023, 02:58 AM
Last Post: Skaperen
  f-strings round float down too much Skaperen 5 2,716 Dec-29-2021, 08:37 PM
Last Post: Skaperen
  f-strings in a script to be made public Skaperen 2 2,223 Jan-03-2020, 06:03 PM
Last Post: Skaperen
  supporting both strings and bytes in functions Skaperen 0 1,481 Nov-28-2019, 03:17 PM
Last Post: Skaperen
  side effects in f-strings Skaperen 0 1,726 Sep-08-2019, 01:26 AM
Last Post: Skaperen
  trying to learn f-strings - puzzled by format() protocol Skaperen 7 3,861 Jul-26-2019, 08:40 PM
Last Post: Skaperen
  mixing bytes with strings Skaperen 3 2,514 May-29-2019, 02:30 AM
Last Post: heiner55
  to strings or to bytes, that is the question Skaperen 0 2,100 Jul-07-2018, 08:35 PM
Last Post: Skaperen
  mutable strings Skaperen 3 3,623 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