Files in Python Buffers. Why a buffer? Computer equipment runs at different speeds, the hard drive and secondary storage in general is MUCH slower than.

Slides:



Advertisements
Similar presentations
Computer Organization. The Nature of Data Spreadsheets give us a way to create processes that manipulate data We can think of a piece of data as a quantity.
Advertisements

Input-Processing-Output
Computer Systems.
Using Computers CS French Chapter 1.
Computer Hardware.
Hardware For your computer. Definition First! Hardware is the equipment that processes data to create information. This includes Keyboard Monitor Printer.
Files in Python The Basics. Why use Files? Very small amounts of data – just hardcode them into the program A few pieces of data – ask the user to input.
Computers What’s in there and how does it work?. Parts of a computer  There are many different parts to a computer. Some are inside the large case that.
Hardware and Multimedia Chapter 4. 4 Personal Computers (PCs) PCs are computers that can be: Used by individuals at home, work, or school Desktop models.
Systems Software Operating Systems.
Computers & Logic An Overview. Hardware Hardware is the equipment, or the devices, associated with a computer. For a computer to be useful, however, it.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Introduction to Computer Administration Introduction.
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
A COMPUTER is an electronic device. Every computer performs 4 general operations: 1. Input 2. Process 3. Output 4. Storage.
Vocabulary Test Review Directions: (Press F5 to start) 1.Click the mouse or use the arrow keys to get to the next slide. 2.Answer the question in your.
XP Practical PC, 3e Chapter 17 1 Upgrading and Expanding your PC.
© Paradigm Publishing Inc. 4-1 Chapter 4 System Software.
Hardware Case that houses the computer Monitor Keyboard and Mouse Disk Drives – floppy disk, hard disk, CD Motherboard Power Supply (PSU) Speakers Ports.
Systems Software & Operating systems
Chapter 4 System Software.
INTRODUCTION TO COMPUTER OPERATION AN OVERVIEW HARDWARE SOFTWARE PERIPHERALS MOTHERBOARD CPU MEMORY OS APPLICATIONS.
Overview of Windows and Microsoft Word. Operating System Performs 3 functions –Controls the hardware of the computer Screen, keyboard, disk drives, etc.
RjpSystem Level Programming Operating Systems 1 Having fun withy the Unix Operating System Praxis Week 7 Rob Pooley.
The Computer and Its Parts Technology Applications (Keyboarding)
Computers Parts/Types. Topics Definition Types of Computers Parts of Computer System Impact on Society.
Computer Hardware Introduction. Computer Hardware Introduction The basic form of a computer is this: PROCESSING MEMORY INPUTOUTPUT But let’s look inside.
Computer Parts Hardware.
Computer Parts. Two Basic Parts Hardware & Software.
Systems in Non-living Things
Processes and OS basics. RHS – SOC 2 OS Basics An Operating System (OS) is essentially an abstraction of a computer As a user or programmer, I do not.
IT253: Computer Organization
Interrupts By Ryan Morris. Overview ● I/O Paradigm ● Synchronization ● Polling ● Control and Status Registers ● Interrupt Driven I/O ● Importance of Interrupts.
© Paradigm Publishing Inc. 4-1 OPERATING SYSTEMS.
Operating Systems. Overview What is an Operating System (OS) What is an Operating System (OS) What Operating Systems do. What Operating Systems do. Operating.
Grade 9 BTT - Hardware Notes. Prepared by: C. Novak - Ridgemont Hardware and Software Hardware is any part of the computer system you can see Software.
Operating Systems Lesson Objective: Understanding the functions of an operating system. Learning Outcome: Answer some basic questions on operating systems.
COMPUTER CONCEPTS Unit A: Computer and Internet Basics 1.
Parts of the Computer System
ICT IGCSE Theory – Revision Presentation 1.2 The Main Components of Computer Systems Chapter 1: Types and components of computer systems
Basic Systems and Software. Were we left off Computers are programmable (formal) machines. Digital information is stored as a series of two states (1.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
Looking Inside the Computer System
Hardware on the Inside.  Computers are made of many electronic components or parts.  These components each have a special job and they all work together.
AS Computing Hardware. Buffers and Interrupts A buffer is an area of memory used for holding data during input/output transfers to and from disk.
CSC 1010 Programming for All Lecture 1 Some material courtesy of Python for Informatics: Exploring Information (
In computing, an input device is a piece of computer hardware equipment used to provide data and control signals to an information processing system such.
ICS2O-What is Computer and Information Science There is a wide variety of definitions for what a computer is or what it does. Our definition for the computer.
What makes up a computer. By Miranda, Ally and Eloise.
By Ellen Glennie & Bella Pearce. The motherboard The motherboard is the main compartment of the computer. The motherboard is the source that everything.
National Diploma Unit 4 Introduction to Software Development Program specification & development.
Midterm OPERATING SYSTEM. Objectives At the end of the course, the student should be able to: Define the operating system; Demonstrate the abstract view.
 Kim  Allen  Kenneth. Chapter 1 Computer Fundamentals.
Parts of the Computer By Zuleikha Chikh. Monitor A monitor displays information in visual form, using text and graphics. The portion of the monitor that.
MEMORY is part of the Central Processing Unit, or CPU, where data and information are stored. There are two main types of memory in a computer – RAM.
WHAT IS COMPUTER ? . A computer is a complex system consisting of both hardware and software components.
IT Chapter 2 Part A How Computers Work Input, process, output, and storage The operating system helps the computer perform four basic operations,
Computer Architecture and Number Systems
Parts of a Computer.
Operating Systems & System Software
Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Describe the central processing unit including its role
Describe the central processing unit including its role
Computer System Basics- The Pieces & Parts
Using files Taken from notes by Dr. Neil Moore
Components of a CPU AS Computing - F451.
The Main Features of Operating Systems
Build Your Own Computer
Computer Electronic device Accepts data - input
Presentation transcript:

Files in Python Buffers

Why a buffer? Computer equipment runs at different speeds, the hard drive and secondary storage in general is MUCH slower than RAM and the CPU, for example This is a bottleneck where the faster pieces have to wait for the slower ones to deliver the action or service or data that is needed Buffers help this bottleneck! They let the OS bring in a bigger chunk of data to RAM and hold it until the program asks for it = not so many trips to the hard drive

What’s a buffer? A buffer is an area of RAM allocated by the OS to manage these bottlenecks Every file you open in your program will have a buffer Also buffers for keyboard, screen, network connections, modems, printers, etc. You the programmer do not have to worry about this happening, it’s automatic!

Buffer for input file When you read from a file, the buffer associated with the file is checked first – if there’s still data in the buffer, that’s what your program gets If the buffer is exhausted, then the OS is told to get some more data from the file on the HD and put it in the buffer This process continues until the program ends or until the file has no more data to read Think of a pantry in a house – it’s a buffer between the people in the house and the supermarket

Buffer for output file You write in your program to an output file The data does NOT go directly, immediately to the hard drive, but to an output buffer The OS monitors this buffer – when it is full, it is all written to the hard drive at one time Think of a garbage can in a house – it is a buffer to hold trash until it can all be taken to the landfill at one time

Why do I care about buffers? You can see most of the action on a buffer is automatic from the point of view of most programmers BUT! if you forget to close your file when you are finished with it, the file can be left in an “unfinished” state! Some OS’s are bad for not cleaning things up when your program is over – they should close all files automatically but sometimes they don’t!

Why do I care? A file in an “unfinished” state may be one of those files you run across after an application has crashed. If you try to erase it, the OS says “no, that file is still busy”, even though it’s not. Especially for output files, your file on the hard drive may not get that last buffer of data that you thought your program wrote to the file if you forget to close the file! The file will be missing data or possibly missing altogether if the file was small.

Before the open happens

After the open

After one readline()

After two more readlines

Don’t forget! Don’t forget to close your files! – and the close statement must look like – infile.close() No arguments in the parentheses but they must be there!