Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > No ValueError for large exponents?

Reply
Thread Tools

No ValueError for large exponents?

 
 
enigmadude
Guest
Posts: n/a
 
      09-06-2006
As many have heard, IronPython 1.0 was released. When I was looking
through the listed differences between CPython and IronPython, the
document mentioned that using large exponents such as 10 **
735293857239475 will cause CPython to hang, whereas IronPython will
raise a ValueError. Trying this on my own machine, it did indeed seem
to cause CPython to hang. In cases such as this, should this be
considered a bug in the CPython implementation that needs to be fixed?
Or is there a reason for this, such as consideration of future changes
and language definition vs language implementation, etc.?

 
Reply With Quote
 
 
 
 
Robin Becker
Guest
Posts: n/a
 
      09-06-2006
enigmadude wrote:
> As many have heard, IronPython 1.0 was released. When I was looking
> through the listed differences between CPython and IronPython, the
> document mentioned that using large exponents such as 10 **
> 735293857239475 will cause CPython to hang, whereas IronPython will
> raise a ValueError. Trying this on my own machine, it did indeed seem
> to cause CPython to hang. In cases such as this, should this be
> considered a bug in the CPython implementation that needs to be fixed?
> Or is there a reason for this, such as consideration of future changes
> and language definition vs language implementation, etc.?
>

I suspect the hang may be python actually trying to work out the
1 followed by 735293857239475 zeroes. Perhaps IronPython has a forward
looking algorithm that knows when to give up early.
--
Robin Becker
 
Reply With Quote
 
 
 
 
Duncan Booth
Guest
Posts: n/a
 
      09-07-2006
Robin Becker <(E-Mail Removed)> wrote:

> enigmadude wrote:
>> As many have heard, IronPython 1.0 was released. When I was looking
>> through the listed differences between CPython and IronPython, the
>> document mentioned that using large exponents such as 10 **
>> 735293857239475 will cause CPython to hang, whereas IronPython will
>> raise a ValueError. Trying this on my own machine, it did indeed seem
>> to cause CPython to hang. In cases such as this, should this be
>> considered a bug in the CPython implementation that needs to be fixed?
>> Or is there a reason for this, such as consideration of future changes
>> and language definition vs language implementation, etc.?
>>

> I suspect the hang may be python actually trying to work out the
> 1 followed by 735293857239475 zeroes. Perhaps IronPython has a forward
> looking algorithm that knows when to give up early.


My guess would be that IronPython preallocates sufficient memory for the
resulting string, so will fail immediately, and CPython must be trying to
grow the string dynamically.
 
Reply With Quote
 
Georg Brandl
Guest
Posts: n/a
 
      09-07-2006
enigmadude wrote:
> As many have heard, IronPython 1.0 was released. When I was looking
> through the listed differences between CPython and IronPython, the
> document mentioned that using large exponents such as 10 **
> 735293857239475 will cause CPython to hang, whereas IronPython will
> raise a ValueError.


What message does that value error have?

If it's a memory issue, the operation should raise MemoryError (at
least in CPython).

Georg
 
Reply With Quote
 
enigmadude
Guest
Posts: n/a
 
      09-10-2006
Georg Brandl wrote:
> enigmadude wrote:
> > As many have heard, IronPython 1.0 was released. When I was looking
> > through the listed differences between CPython and IronPython, the
> > document mentioned that using large exponents such as 10 **
> > 735293857239475 will cause CPython to hang, whereas IronPython will
> > raise a ValueError.

>
> What message does that value error have?
>
> If it's a memory issue, the operation should raise MemoryError (at
> least in CPython).
>
> Georg


I haven't run IronPython yet, but the "Differences" document says that
IronPython would raise a ValueError. It wasn't any more specific than
that. As far as CPython, I didn't wait long enough for it to raise a
MemoryError if it was going to raise one at all. From a user point of
view, CPython appeared to hang for about one minute, slowly raising CPU
usage and RAM usage, before I finally decided to just kill the process.
I don't know whether or not it would have completed 5 minutes later or
whether it would hang indefinitely, I haven't tested it. Although I may
be overreacting, I would wonder about the ramifications of something
like this hanging the interpreter (possible vector for DOS attack on an
webapp server, or even the machine itself if it balloons RAM usage?).
I'm not trying to be a doomsayer or anything, but I just want to know
how CPython handles extreme cases like this.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ValueError: invalid literal for int(): 1.0000000000e+00 =?ISO-8859-2?Q?Martin_MOKREJ=A9?= Python 1 02-14-2005 05:22 PM
Pickled text file causing ValueError (dos/unix issue) Aki Niimura Python 12 01-15-2005 04:05 PM
MySQLdb returns "ValueError: invalid literal for float():" for cursor.execute('show databases') Tim Williams Python 2 05-28-2004 12:48 PM
ValueError: argument is not a COM object Stefano Masini Python 0 05-18-2004 01:10 PM
logging.shutdown() ValueError: I/O operation on closed file j vickroy Python 5 11-14-2003 08:19 AM



Advertisments