Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82818

Re: Program calling unwanted functions

Date 2014-12-22 18:57 -0500
From Dave Angel <davea@davea.name>
Subject Re: Program calling unwanted functions
References <b37a93ec-c90b-4375-a264-e96c3128871b@googlegroups.com> <5498808D.60305@davea.name> <CALwzidkPhDPVfw_Gx_cEDPvDmi=1mzda4uJ1HtcdwP39Cw1X_Q@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17145.1419292640.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 12/22/2014 06:48 PM, Ian Kelly wrote:
> On Dec 22, 2014 2:37 PM, "Dave Angel" <davea@davea.name> wrote:
>>
>> I'll pick on one function first, called instructions().  If the user
> types something invalid, you print "Invalid input." and call the function
> again.  In this case, because the call is at the end, no harm is usually
> done, but it would be tricky to explain why.  If the user happened to type
> the wrong input 1000 times, you'd hit a recursion limit and crash, but
> that's unlikely unless you have a very stubborn user.
>
> Point of interest, Python (or at least CPython) doesn't optimize tail-call
> recursion, so in fact this sort of unbounded recursion (a "stack leak", if
> you will) is equally bad no matter where it appears in the function.
>

Which is exactly why I mentioned the recursion limit of about 1000.


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Program calling unwanted functions Luke Tomaneng <luketomaneng@gmail.com> - 2014-12-22 11:55 -0800
  Re: Program calling unwanted functions John Gordon <gordon@panix.com> - 2014-12-22 20:09 +0000
  Re: Program calling unwanted functions Dave Angel <davea@davea.name> - 2014-12-22 15:35 -0500
  Re: Program calling unwanted functions Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-22 16:48 -0700
  Re: Program calling unwanted functions Dave Angel <davea@davea.name> - 2014-12-22 18:57 -0500
    Re: Program calling unwanted functions sohcahtoa82@gmail.com - 2014-12-22 16:04 -0800
      Re: Program calling unwanted functions Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-22 17:12 -0700
      Re: Program calling unwanted functions Dave Angel <davea@davea.name> - 2014-12-22 19:12 -0500

csiph-web