This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients eric.smith, mrabarnett, pablogsal, rhettinger, serhiy.storchaka, terry.reedy, veky, xtreak
Date 2021-03-20.01:34:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616204085.32.0.968952811703.issue43535@roundup.psfhosted.org>
In-reply-to
Content
I am sympathetic to the 'hiding bugs' argument in general, but what bugs would this proposal hide?  What bugs does print hide by auto-converting non-strings to strings?

I recently had the same thought as Raymond's: "it would be nice if str.join converted inputs to strings when needed."

I have always known that print() is slower in IDLE than in a console.  A recent SO question https://stackoverflow.com/questions/66286367/why-is-my-function-faster-than-pythons-print-function-in-idle showed that it could be 20X slower and asked why?  It turns out that while

print(*values, sep=sep, end=end, file=file) # is equivalent to file.write(sep.join(map(str, values))+end)

print must be implemented as the C equivalent of something like

first=True
for val in values:
    if first:
        first = False
    else
        file.write(sep)
    file.write(str(value))
file.write(end)

When sys.stdout is a screen buffer, the multiple writes effectively implement a join.  But in IDLE, each write(s) results in a separate socket.send(s.encode) and socket.receive).decode + text.insert(s, tag).  I discovered that removing nearly all the overhead from the very slow example with sep.join and end.join made the example only trivially slower on IDLE (5%) than the standard REPL.  In #43283 I added the option of speedups using .join and .format to the IDLE doc, but this workaround would be much more usable if map(str, x) were not needed.
History
Date User Action Args
2021-03-20 01:34:45terry.reedysetrecipients: + terry.reedy, rhettinger, eric.smith, mrabarnett, serhiy.storchaka, veky, pablogsal, xtreak
2021-03-20 01:34:45terry.reedysetmessageid: <1616204085.32.0.968952811703.issue43535@roundup.psfhosted.org>
2021-03-20 01:34:45terry.reedylinkissue43535 messages
2021-03-20 01:34:45terry.reedycreate