Clarify stdout flush behavior for newline characters inside a single print() call#1
Open
Vemulakonda559 wants to merge 639 commits intomainfrom
Open
Clarify stdout flush behavior for newline characters inside a single print() call#1Vemulakonda559 wants to merge 639 commits intomainfrom
Vemulakonda559 wants to merge 639 commits intomainfrom
Conversation
…ic release artifacts (python#142405) Co-authored-by: Steve Dower <steve.dower@microsoft.com> Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
…2290) This roughly follows what was done for dictobject to make a lock-free lookup operation. With this change, the set contains operation scales much better when used from multiple-threads. The frozenset contains performance seems unchanged (as already lock-free). Summary of changes: * refactor set_lookkey() into set_do_lookup() which now takes a function pointer that does the entry comparison. This is similar to dictobject and do_lookup(). In an optimized build, the comparison function is inlined and there should be no performance cost to this. * change set_do_lookup() to return a status separately from the entry value * add set_compare_frozenset() and use if the object is a frozenset. For the free-threaded build, this avoids some overhead (locking, atomic operations, incref/decref on key) * use FT_ATOMIC_* macros as needed for atomic loads and stores * use a deferred free on the set table array, if shared (only on free-threaded build, normal build always does an immediate free) * for free-threaded build, use explicit for loop to zero the table, rather than memcpy() * when mutating the set, assign so->table to NULL while the change is a happening. Assign the real table array after the change is done.
…ython#142658) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
* Commit * Skip if tzdata version does not match * Mark as generated * Update to 2025.3
…justments in 3.13 (python#142413)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
…thon#142592) Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
…ythonGH-136070) Signed-off-by: Manjusaka <me@manjusaka.me>
…onGH-142667) The variable was previously used, but became unused after 133138a. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
…ction.getresponse` (python#142339)
…_O` (pythonGH-142695) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
…#127931) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
… `__version__` attributes (python#139997)
…ython#142676) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…,in}dent`` (python#131924) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…andlers (pythonGH-143259) This fixes regression introduced in pythonGH-105887.
If you are building with `--with-thread-sanitizer` and don't use the suppression file, then running configure will report a thread leak. Call `pthread_join()` to avoid the thread leak.
…Handler (pythonGH-137860) Add RegisterEventSource(), DeregisterEventSource(), ReportEvent() and a number of EVENTLOG_* constants to _winapi.
…erpreter.ExecutionFailed` (python#141723) Remove documentation for inexistant `concurrent.futures.interpreter.ExecutionFailed` and replace its occurrences by `concurrent.interpreters.ExecutionFailed` since this is the documented exception.
2d66675 to
c3c6dab
Compare
…ive Mode" docs (python#143049)
…O, _METHOD_DESCRIPTOR_O} (pythonGH-143330) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
…T` (pythonGH-143320) Signed-off-by: Manjusaka <me@manjusaka.me> Co-authored-by: Ken Jin <kenjin4096@gmail.com>
…pythonGH-143333) Fix test to reflect real-world usage
…ystem (python#142360) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This PR adds a note to the print() documentation to clarify how Python’s stdout buffering works with newline (\n) characters inside a single print call. Motivation: Current documentation mentions that flush() is implied for writes containing newlines. However, it does not explain that Python flushes only after the entire write operation, not mid-string. This can confuse users coming from C, who expect a flush at each newline, and developers writing scripts that rely on immediate output for progress indicators or CLI feedback. What’s added: A .. note:: block explaining that stdout behavior depends on the environment (TTY vs redirected stdout). Guidance on explicitly flushing with flush=True or sys.stdout.flush(). Mention of python -u for unbuffered output. A short example demonstrating the behavior. Impact: Improves clarity for learners and developers. Aligns documentation with actual behavior across different environments. Not a behavior change — documentation-only PR. Related Issue: Addresses issue python#141395
Removed duplicate text and improved clarity in the note about stdout flushing behavior.
Removed redundant sentence about output buffering.
Removed unnecessary comments about string flushing in print.
Remove extra blank lines and fix indentation for versionchanged directive.
Reformat output buffering explanation for clarity.
c3c6dab to
0ece9e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a note to the print() documentation to clarify how Python’s stdout buffering works with newline (\n) characters inside a single print call.
Motivation:
Current documentation mentions that flush() is implied for writes containing newlines.
However, it does not explain that Python flushes only after the entire write operation, not mid-string.
This can confuse users coming from C, who expect a flush at each newline, and developers writing scripts that rely on immediate output for progress indicators or CLI feedback.
What’s added:
A .. note:: block explaining that stdout behavior depends on the environment (TTY vs redirected stdout).
Guidance on explicitly flushing with flush=True or sys.stdout.flush().
Mention of python -u for unbuffered output.
A short example demonstrating the behavior.
Impact:
Improves clarity for learners and developers.
Aligns documentation with actual behavior across different environments.
Not a behavior change — documentation-only PR.
Related Issue:
Addresses issue python#141395