Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-26 Thread Greg Ewing
Nick Maclaren wrote: The compiled code has made a data structure temporarily inconsistent because the operation is safe (say, list insertion), and then gets an asynchronous interrupt (e.g. SIGINT). The SIGINT handler does some operation (e.g. I/O) that implicitly uses floating-point, which

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-26 Thread Raymond Hettinger
Greg Ewing And all of this is getting rather far away from where we started, which was simply instrumenting a piece of code to count floating point exceptions. I'm thinking of adding a note to the Py2.5 docs that the counting feature is not part of the standard and should not be expected to

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-26 Thread Facundo Batista
2006/7/26, Raymond Hettinger [EMAIL PROTECTED]: Greg Ewing And all of this is getting rather far away from where we started, which was simply instrumenting a piece of code to count floating point exceptions. I'm thinking of adding a note to the Py2.5 docs that the counting feature is

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-25 Thread Nick Maclaren
Greg Ewing [EMAIL PROTECTED] wrote: But we weren't talking about asynchronous exceptions, we were talking about floating point exceptions. Unless your TLB miss handler uses floating point arithmethic, there's no way it can get interrupted by one. (And if it does use floating point

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-24 Thread Nick Maclaren
James Y Knight [EMAIL PROTECTED] wrote: To cut a long story short, it is impractical for a language run-time system to call user-defined handlers with any degree of reliability unless the compiled code and run-time interoperate carefully - I have been there and done that many times, but

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-21 Thread Nick Maclaren
Greg Ewing [EMAIL PROTECTED] wrote: Now, interrupting into that level has to be transparent, in order to support TLB misses, clock interrupts, device interrupts, machine-check interrupts and so on. I thought we were just talking about counting the number of floating point exceptions

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-21 Thread James Y Knight
On Jul 21, 2006, at 6:18 AM, Nick Maclaren wrote: To cut a long story short, it is impractical for a language run-time system to call user-defined handlers with any degree of reliability unless the compiled code and run-time interoperate carefully - I have been there and done that many times,

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-20 Thread Nick Maclaren
Greg Ewing [EMAIL PROTECTED] wrote: But couldn't you just put in an interrupt handler that counts the interrupts, for the purpose of measurement? No, but the reasons are very arcane. The general reason is that taking an interrupt handler and returning is not transparent, and is often not

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-20 Thread Greg Ewing
Nick Maclaren wrote: Now, interrupting into that level has to be transparent, in order to support TLB misses, clock interrupts, device interrupts, machine-check interrupts and so on. I thought we were just talking about counting the number of floating point exceptions that a particular piece

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Georg Brandl
Raymond Hettinger wrote: Aahz wrote: On Tue, Jul 18, 2006, Raymond Hettinger wrote: P.S. The dictionary approach to context objects should likely be abandoned for the C version. If the API has to change a bit, then so be it. Why do you say that? The rest I agree with; seems to

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Nick Coghlan
Georg Brandl wrote: Raymond Hettinger wrote: If the current approach gets in their way, the C implementers should feel free to make an alternate design choice. +1. (cDecimal is an ugly name, but a sound concept) I don't know what progress Mateusz' work has made until now, but he wrote

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Raymond Hettinger
I think it was tripping-up the folks working on the C implementation. Georg can speak to it more directly. IIRC, the issue was that the context object exposed a dictionary which a user could update directly and there was no notification back to the surrounding object so it could

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Nick Maclaren
Georg Brandl [EMAIL PROTECTED] wrote: Even then, we need to drop the concept of having the flags as counters rather than booleans. Yes. Given that even Tim couldn't imagine a use case for counting the exceptions, I think it's sensible. Well, I can. There is a traditional, important use -

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Tim Peters
... [Raymond] Even then, we need to drop the concept of having the flags as counters rather than booleans. [Georg Brandl] Yes. Given that even Tim couldn't imagine a use case for counting the exceptions, I think it's sensible. That's not it -- someone will find a use for anything. It's

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Greg Ewing
Nick Maclaren wrote: When such arithmetic is implemented in hardware, it is normal for exceptional cases to be handled by interrupt, and that is VERY expensive ... It then becomes important to know how many of the things you got, to know whether it is worth putting code in to avoid them or

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-19 Thread Raymond Hettinger
Tim Peters wrote: ... [Raymond] Even then, we need to drop the concept of having the flags as counters rather than booleans. [Georg Brandl] Yes. Given that even Tim couldn't imagine a use case for counting the exceptions, I think it's sensible.

[Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Raymond Hettinger
I briefly had a chance to look at some of the work being done on a C implementation of decimal, and it looks like the approach is following the Python version too literally. Ideally, it should be written as if Python were not involved and afterwards add the appropriate method wrappers.

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Aahz
On Tue, Jul 18, 2006, Raymond Hettinger wrote: P.S. The dictionary approach to context objects should likely be abandoned for the C version. If the API has to change a bit, then so be it. Why do you say that? The rest I agree with; seems to me that making a small wrapper for dict access

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Tim Peters
[Raymond Hettinger] ... If the current approach gets in their way, the C implementers should feel free to make an alternate design choice. I expect they will, eventually. Converting this to C is a big job, and at the NFS sprint we settled on an incremental strategy allowing most of the

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Raymond Hettinger
Aahz wrote: On Tue, Jul 18, 2006, Raymond Hettinger wrote: P.S. The dictionary approach to context objects should likely be abandoned for the C version. If the API has to change a bit, then so be it. Why do you say that? The rest I agree with; seems to me that making

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Lisandro Dalcin
On 7/18/06, Tim Peters [EMAIL PROTECTED] wrote: [Raymond Hettinger] ... If the current approach gets in their way, the C implementers should feel free to make an alternate design choice. I expect they will, eventually. Converting this to C is a big job, and at the NFS sprint we

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Raymond Hettinger
Lisandro Dalcin wrote: On 7/18/06, Tim Peters [EMAIL PROTECTED] wrote: [Raymond Hettinger] ... If the current approach gets in their way, the C implementers should feel free to make an alternate design choice. I expect they will, eventually.

Re: [Python-Dev] Strategy for converting the decimal module to C

2006-07-18 Thread Giovanni Bajo
Tim Peters wrote: Changing the user-visible API is a hard egg to swallow, and it's unfortunate that the Python code used a dict to hold flags to begin with. The dict doesn't just record whether an exception has occurred, it also counts how many times the exception occurred. It's possible