No ValueError for large exponents?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • enigmadude

    No ValueError for large exponents?

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

  • Robin Becker

    #2
    Re: No ValueError for large exponents?

    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

    Comment

    • Duncan Booth

      #3
      Re: No ValueError for large exponents?

      Robin Becker <robin@NOSPAMre portlab.comwrot e:
      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 **
      >73529385723947 5 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.

      Comment

      • Georg Brandl

        #4
        Re: No ValueError for large exponents?

        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

        Comment

        • enigmadude

          #5
          Re: No ValueError for large exponents?

          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 "Difference s" 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.

          Comment

          Working...