Re[2]: [Haskell-cafe] Speed of character reading in Haskell

2007-09-09 Thread Bulat Ziganshin
Hello ok, Monday, September 10, 2007, 6:09:27 AM, you wrote: >> Locks: getChar has to acquire locks, as does getContents. However, >> because getContents can operate on blocks, this requires many fewer >> locks. > What's to lock against? I'm writing single-threaded code. unfortunately, there is

Re[2]: [Haskell-cafe] Speed of character reading in Haskell

2007-09-09 Thread Bulat Ziganshin
Hello Neil, Monday, September 10, 2007, 3:49:06 AM, you wrote: >> I'm sure it's true, but it's quite irrelevant to my question, which is >> "why is using getChar so much slower than using getContents"? > Buffering, blocks and locks. in ghc, is entirely due to locking, which is the slowest opera

Re: [Haskell-cafe] Speed of character reading in Haskell

2007-09-09 Thread ok
On 10 Sep 2007, at 11:49 am, Neil Mitchell wrote: Buffering, blocks and locks. Buffering: getChar demands to get a character now, which pretty much means you can't buffer. Eh what? getchar() in C "demands to get a character now", which is fully compatible with as much buffering as you want.

Re: [Haskell-cafe] Speed of character reading in Haskell

2007-09-09 Thread Derek Elkins
On Mon, 2007-09-10 at 00:49 +0100, Neil Mitchell wrote: > Hi > > > > (Some list operations are too expensive with ByteString but for most > > > string processing it's perfectly fine and much faster than String). > > > > I'm sure it's true, but it's quite irrelevant to my question, which is > > "wh

Re: [Haskell-cafe] Speed of character reading in Haskell

2007-09-09 Thread Neil Mitchell
Hi > > (Some list operations are too expensive with ByteString but for most > > string processing it's perfectly fine and much faster than String). > > I'm sure it's true, but it's quite irrelevant to my question, which is > "why is using getChar so much slower than using getContents"? Buffering,

Re: [Haskell-cafe] Speed of character reading in Haskell

2007-09-09 Thread ok
On 7 Sep 2007, at 11:22 pm, Chaddaï Fouché wrote: From what I can see of your program, it would greatly benefit from using Data.ByteString, is there an obvious reason not to use it ? I am writing a a set of tools to process a legacy programming language, as I said. Speed is not, in fact, a ce

Re: [Haskell-cafe] Speed of character reading in Haskell

2007-09-07 Thread Chaddaï Fouché
>From what I can see of your program, it would greatly benefit from using Data.ByteString, is there an obvious reason not to use it ? (Some list operations are too expensive with ByteString but for most string processing it's perfectly fine and much faster than String). -- Jedaï _

Re: [Haskell-cafe] Speed of character reading in Haskell

2007-09-06 Thread Miguel Mitrofanov
> I started with the obvious > main = getContents >>= print . tokenise > where tokenise maps its way down a list of characters. This is very > simple, very pleasant, and worked like a charm. > However, the language has an INCLUDE directive, so I'm going to have > to call readFile or somethin

[Haskell-cafe] Speed of character reading in Haskell

2007-09-06 Thread ok
I'm writing a tokeniser for a legacy programming language in Haskell. I started with the obvious main = getContents >>= print . tokenise where tokenise maps its way down a list of characters. This is very simple, very pleasant, and worked like a charm. However, the language has an INCLUD