Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'subject:Python': 0.06; 'string': 0.09; 'appropriate.': 0.09; 'formatting': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(use': 0.16; '23,': 0.16; 'expression,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inputs': 0.16; 'splitting': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'parse': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'subject:/': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'wondering': 0.29; 'feature': 0.29; 'am,': 0.29; 'generally': 0.29; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'fast.': 0.31; 'with,': 0.31; 'regular': 0.32; 'maybe': 0.34; 'something': 0.35; 'more,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'performance': 0.37; 'problems': 0.38; 'easiest': 0.38; 'whatever': 0.38; 'explain': 0.39; 'either': 0.39; 'future': 0.60; 'solve': 0.60; 'competitive': 0.61; "you're": 0.61; "you'll": 0.62; 'more': 0.64; 'price': 0.69; 'jul': 0.74; 'comparable': 0.84; 'to:none': 0.92; 'yourself,': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=zVyNkovZjfKPdP+13j5lpZp0oHGYL3MURjUA2fZ3Bhs=; b=qey9bsimvSJIz+5CjzZGoA1QaMCd8wgmAbgywOr+skozOZDjCwnzFlm9cPeuZM9mg/ dAwPaNYQBI73xdQwfxqLKx8VUIWMjC8UXvrDZwiG+ACpvFsYENeq7aNKhMVZBvpsvQIx zCLwpPyzbj8o849tkcUyQhG7MHDpD//F/vRtg5/A3WKhRHs3w8VtUIbJpfBXuJrJEpED EYQikrjLtfQzS08uTpjIy0jaNUxgNiV5APyNoYHwwD8En158l+OAuRjEL7bOqSa1Mlyf vH8bB1MErh8F0Mhm3orZnaTLtmW2CWW8C8HDpmYP10Fu7RLIIHERyG+yDsidOPThJaqZ v+LA== MIME-Version: 1.0 X-Received: by 10.52.119.179 with SMTP id kv19mr35349387vdb.3.1406045847166; Tue, 22 Jul 2014 09:17:27 -0700 (PDT) In-Reply-To: References: Date: Wed, 23 Jul 2014 02:17:27 +1000 Subject: Re: Fastest I/O on Python ? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406045849 news.xs4all.nl 2918 [2001:888:2000:d::a6]:44273 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75002 On Wed, Jul 23, 2014 at 2:06 AM, Orochi wrote: > Is there in any other input/output faster than ("raw_input","input" / "print") > As I am trying to solve competitive Programs on codechef.com using python i was wondering if there is any other way to print and scan the inputs fast. What do you mean by faster? Are you really seeing performance problems with them, or are you actually looking for something like C's printf and scanf, which do more than just output and input? The print function (use either Python 3 or a future import) has some good formatting facilities, and if you need more, you can do something like this: >>> print("The price is $%.2f per kilo." % 1.5) The price is $1.50 per kilo. However, there's no comparable feature for input. It's generally easiest to take a string from (raw_)input and then parse it yourself, maybe with a regular expression, or splitting it on whitespace, or whatever else is appropriate. But you'll really need to explain what you're actually having issues with, before we can advise further. ChrisA