Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8986953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:40:29+00:00 2026-06-15T21:40:29+00:00

Possible Duplicate: what exactly the python’s file.flush() is doing? I find that calling the

  • 0

Possible Duplicate:
what exactly the python’s file.flush() is doing?

I find that calling the flush method costs many IO operations, which leads to extra time.

I know that if I take out flush in my script, the file will not be updated immediately.

So I wonder if I’m only writing but not reading a file, is there any other side-effect of taking out flush from script?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:40:30+00:00Added an answer on June 15, 2026 at 9:40 pm

    Side effects? I dont exactly understand what you mean but let me have ago at it anyway.

    For file operations, Python uses the operating system’s default buffering unless you configure it do otherwise. You can specify a buffer size, unbuffered, or line buffered. So If you are constantly using flush there is constant IO going on and If you are flushing out large amounts of data (i.e. buffer being big) this could slow does other running programs which could end up waiting for IO.

    Fast and frequent IO operations are not good for the life of a harddisk, it increases changes of disk crashes.

    Typically the pattern I follow is after all the writing to file object is done, flush is done at the end before closing the file.

    Something for you to think about, are there other threads or programs reading from the same file as you are writing it? If this is the case you might get into trouble! Corrupt files are very much a possibility here. If you are considering using file as a persistent data store. Then its the wrong way to do it. Why not consider using a persistent-DB (like mysql or even sqlite) instead of using a file as a data store.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: JavaScript: formatting number with exactly two decimals Now that I have got
Possible Duplicate: What the .NET standard for remote method invocation? What exactly is C#
Possible Duplicate: Difference Between Equals and == in which cases equals() works exactly like
Possible Duplicate: .htaccess redirect How exactly, with a .htaccess file i'm presuming, would i
Possible Duplicate: JavaScript: formatting number with exactly two decimals Can some one please help
Possible Duplicate: What does “$?” give us exactly in a shell script? What does
Possible Duplicate: How exactly does dependency injection reduce coupling? Dependency Injection as a concept,
Possible Duplicate: JavaScript: formatting number with exactly two decimals How do I limit the
Possible Duplicate: Learning about LINQ Hi everyone, I just want to understand what exactly
Possible Duplicate: When do we have to use copy constructors? Why exactly are C++

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.