How to write fast into a file in python?

MRAB python at mrabarnett.plus.com
Sun May 19 11:44:55 EDT 2013


On 19/05/2013 04:53, Carlos Nepomuceno wrote:
> ----------------------------------------
>> Date: Sat, 18 May 2013 22:41:32 -0400
>> From: davea at davea.name
>> To: python-list at python.org
>> Subject: Re: How to write fast into a file in python?
>>
>> On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:
>>> Python really writes '\n\r' on Windows. Just check the files.
>>
>> That's backwards. '\r\n' on Windows, IF you omit the b in the mode when
>> creating the file.
>
> Indeed! My mistake just made me find out that Acorn used that inversion on Acorn MOS.
>
> According to this[1] (at page 449) the OSNEWL routine outputs '\n\r'.
>
> What the hell those guys were thinking??? :p
>
Doing it that way saved a few bytes.

Code was something like this:

FFE3    .OSASCI CMP #&0D
FFE5            BNE OSWRCH
FFE7    .OSNEWL LDA #&0A
FFE9            JSR OSWRCH
FFEC            LDA #&0D
FFEE    .OSWRCH ...

This means that the contents of the accumulator would always be
preserved by a call to OSASCI.

> "OSNEWL
> This call issues an LF CR (line feed, carriage return) to the currently selected
> output stream. The routine is entered at &FFE7."
>
> [1] http://regregex.bbcmicro.net/BPlusUserGuide-1.07.pdf 		 	   		
>




More information about the Python-list mailing list