Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'essentially': 0.04; 'argument': 0.05; 'arguments': 0.09; 'arguments,': 0.09; 'cc:addr :python-list': 0.11; 'missed': 0.12; 'args.': 0.16; 'argument,': 0.16; 'bool': 0.16; 'callable': 0.16; 'converted,': 0.16; 'cool.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "function's": 0.16; 'hmm.': 0.16; 'optional': 0.16; 'optional.': 0.16; 'stats': 0.16; 'travis': 0.16; 'wrote:': 0.18; 'library': 0.18; 'wed,': 0.18; 'module': 0.19; 'split': 0.19; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'load': 0.23; 'tells': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'constant': 0.31; 'reflected': 0.31; 'core': 0.34; 'maybe': 0.34; 'subject:with': 0.35; 'tool': 0.35; 'one,': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'useful': 0.36; 'thanks': 0.36; 'wrong': 0.37; 'being': 0.38; 'branch': 0.38; 'writes': 0.38; '12,': 0.39; 'environment.': 0.39; 'flow': 0.39; 'called': 0.40; 'remove': 0.60; 'improved': 0.60; 'problems.': 0.60; "you're": 0.61; 'more': 0.64; 'skip:\xe2 10': 0.65; 'default': 0.69; 'obvious': 0.74; '8bit%:46': 0.78; 'can\xe2\x80\x99t': 0.84; 'idiom': 0.84; 'isolate': 0.84; 'it\xe2\x80\x99s': 0.84; 'technically': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=7U9Nej0gOd21UUvMjf7XEnZfomra3vHIO5f/HeKLIzo=; b=qBAnYDMYHzNvcaDsJe1kAj4VYnFbE67OImLU9zbeC8iZmCqKRNh0W51lwo+8r7u+I6 i15P6Sd4O2IMR6OlkLM5UxKYChlnVUdGQfQvaBHeoHEf7gbnBmQFx/xlGtIzVYqNvrax k/DnCpspbChtgx1TuiyMwRTBgkOHyeLihDd8CD1KbzNuiIXmtwI/4TE/hJqZeH43SS0c 19Rl8GjCI2gqUyytUV+xDfqWaazsRomgtg+WipyhXBVcE+wCyRnIBxzV3VUCRhVqpwp6 PJ571E/kKkU8suNd1uplDe4a70/U9DvGdfO+WcGbgfj8jmWvyG135bv0IMTu2oAjMzt5 cRrA== MIME-Version: 1.0 X-Received: by 10.66.118.71 with SMTP id kk7mr35809415pab.14.1392167149549; Tue, 11 Feb 2014 17:05:49 -0800 (PST) In-Reply-To: <5A4B42E0-BE7F-415F-87D4-8A6B3A98D81D@gmail.com> References: <5A4B42E0-BE7F-415F-87D4-8A6B3A98D81D@gmail.com> Date: Wed, 12 Feb 2014 12:05:49 +1100 Subject: Re: Fun with function argument counts From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392167152 news.xs4all.nl 2832 [2001:888:2000:d::a6]:54030 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65969 On Wed, Feb 12, 2014 at 11:34 AM, Travis Griggs wr= ote: > 1) I did not want to try load all modules at once into my environment. I = suspect that would create problems. Using os.fork() to isolate the load/ana= lysis of each module was a handy way to deal with that. The trick of using = if pid: branch to split of the flow of execution was cool. Maybe it=E2=80= =99s the wrong tool for the job and I missed an obvious one, but I thought = it was kinda clever. > That's the normal way to use fork() in any environment. The standard C idiom is to call fork(), and then test for *three* possibilities: 0 means you're in the child, >0 means you're in the parent, and <0 means you're still in the parent, and forking failed. Python simplifies that a bit by raising an error if something goes wrong, so you can simply: if os.fork(): # Parent continues else: # Child process > 2) Using cpython, a lot of the core library can=E2=80=99t be reflected on That's being improved as of 3.4, thanks to Argument Clinic. Though the whole stdlib might not be converted, so you might have to wait for 3.5. > 4) optional arguments were an interesting dillema. I chose to reduce the = argument count of a signature by the number of default arguments. Since the= y are essentially optional. So the stats there have a bias to the =E2=80=9C= minimal=E2=80=9D call signature. > That's one way to look at it. That tells you what can be called with no args. But it's not always a fair look at the function's usefulness; maybe with no arguments, it always returns a constant value: >>> bool() False The bool function (really the type/constructor) is much more useful with an argument, but it's technically callable without. > 6) Who writes a function with 19 mandatory arguments anyway???? subproce= ss._execute_child() and distutils.cygwincompiler._execute_child() Hmm. Those are internal functions (leading underscore). Might be fairer to remove those from consideration. ChrisA