No ValueError for large exponents?

Discussion in 'Python' started by enigmadude, Sep 7, 2006.

  1. enigmadude

    enigmadude Guest

    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.?
     
    enigmadude, Sep 7, 2006
    #1
    1. Advertising

  2. enigmadude

    Robin Becker Guest

    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
     
    Robin Becker, Sep 7, 2006
    #2
    1. Advertising

  3. enigmadude

    Duncan Booth Guest

    Robin Becker <> 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.
     
    Duncan Booth, Sep 7, 2006
    #3
  4. enigmadude

    Georg Brandl Guest

    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
     
    Georg Brandl, Sep 7, 2006
    #4
  5. enigmadude

    enigmadude Guest

    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.
     
    enigmadude, Sep 10, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kwaj

    Exponents in VHDL?

    Kwaj, Aug 19, 2004, in forum: VHDL
    Replies:
    2
    Views:
    14,900
    anupam
    Aug 20, 2004
  2. David
    Replies:
    14
    Views:
    6,468
    Richard Herring
    Apr 21, 2004
  3. geremy condra
    Replies:
    1
    Views:
    604
    Mark Dickinson
    Mar 8, 2010
  4. geremy condra
    Replies:
    4
    Views:
    563
    Mark Dickinson
    Mar 10, 2010
  5. geremy condra
    Replies:
    0
    Views:
    437
    geremy condra
    Mar 8, 2010
Loading...

Share This Page