No ValueError for large exponents?

E

enigmadude

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.?
 
R

Robin Becker

enigmadude said:
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.
 
D

Duncan Booth

Robin Becker said:
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.
 
G

Georg Brandl

enigmadude said:
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
 
E

enigmadude

Georg said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top