Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28940
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joshua.landau.ws@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'example:': 0.03; 'argument': 0.04; 'compiler': 0.05; 'say,': 0.05; '#define': 0.07; 'converts': 0.07; 'function,': 0.07; 'semantic': 0.07; 'python': 0.09; 'macros': 0.09; 'optimizing': 0.09; 'sep': 0.09; 'cc:addr:python-list': 0.10; 'language': 0.14; 'languages.': 0.15; 'ah,': 0.16; 'constants': 0.16; 'in-line': 0.16; 'macro': 0.16; 'macros.': 0.16; 'silly': 0.16; 'subject:variable': 0.16; 'twice.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'instance,': 0.17; 'tend': 0.17; '(in': 0.18; '>>>': 0.18; 'question.': 0.20; "i'd": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'guess': 0.27; 'separate': 0.27; 'c++': 0.27; 'functions.': 0.27; 'in.': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'lines': 0.28; 'chris': 0.28; "d'aprano": 0.29; 'overhead': 0.29; 'steven': 0.29; 'definition': 0.29; 'handled': 0.29; 'no,': 0.29; 'probably': 0.29; "i'm": 0.29; 'that.': 0.30; 'evaluation': 0.30; 'keyword': 0.30; 'function': 0.30; 'sense': 0.31; 'gets': 0.32; 'could': 0.32; 'hopefully': 0.33; 'int': 0.33; 'problem': 0.33; 'knowledge': 0.33; 'languages': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'along': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'add': 0.36; 'but': 0.36; 'wanted': 0.36; '12,': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'things': 0.38; 'sure': 0.38; 'performance': 0.39; 'apply': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'most': 0.61; 'side': 0.61; "you'll": 0.62; 'solve': 0.62; 'day.': 0.63; 'more': 0.63; 'fun': 0.64; 'differences': 0.65; 'wanting': 0.65; 'fact,': 0.69; 'overhead,': 0.84; 'valid,': 0.84; 'write:': 0.91 |
| 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:to :cc:content-type; bh=FrDu2LP62zZ1tUOvefj47q1FgbE7bOz1r17DlB+30gQ=; b=X5LMOSNlt1bFHm37+QnIUT7nMesGnhXjjWmH+DJOhcvepJZw4KHvcDYV8GJ/sAaL7g TEpJpBnD+QKRvNQN5DbKupsh4oAWBgHWwhFZABURmMj+7LLQYRdTr3t0ybfCMulaq21C jmVwquHHiKmWcQjD953wkUXwvUkix/QfMsfTWnMvlqyRhqBGeXwD3g3UkOR0aBj0aWrf n402Y/ER/Am1zpwSP8KbWPEoBftBfba8jIfvbYRTfY+/KTs0U99mDYmp4cjbitWip7n2 PIcI4vcUkO6EtIwZrHW1QIG+TFrg+Q76JEKtuOiF6hGzgyZmhppBnaEOugUIYvKYuudZ XpaA== |
| MIME-Version | 1.0 |
| In-Reply-To | <CAPTjJmoRaOEwDfivNoshHkvnLY3qyELkadooon3EZq3x5Eyvhg@mail.gmail.com> |
| References | <CAN1F8qXpeHAQGJG9urY2NjL_01gX++cMhkgiD3mt3nZsYzYcJQ@mail.gmail.com> <CAPTjJmqh8V9kZm3bQ-BHGDc-qsEuxykh8DCg4s3z5x+JcxW-WA@mail.gmail.com> <CAN1F8qUuXho43hPdGKyh3sAyZHx7JegFfSEU+JhqwyA552a=DA@mail.gmail.com> <mailman.526.1347403933.27098.python-list@python.org> <504fe1e7$0$29981$c3e8da3$5496439d@news.astraweb.com> <CAN1F8qW_3r5X9cDC_CF3QSTL0zRn4S9YX=30vduU8aU+aSN-3A@mail.gmail.com> <CAPTjJmoRaOEwDfivNoshHkvnLY3qyELkadooon3EZq3x5Eyvhg@mail.gmail.com> |
| Date | Wed, 12 Sep 2012 10:55:58 +0100 |
| Subject | Re: Double sided double underscored variable names |
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.545.1347443761.27098.python-list@python.org> (permalink) |
| Lines | 66 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1347443761 news.xs4all.nl 6855 [2001:888:2000:d::a6]:34967 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28940 |
Show key headers only | View raw
On 12/09/2012, Chris Angelico <rosuav@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 11:38 AM, Joshua Landau
> <joshua.landau.ws@gmail.com> wrote:
>> On 12 September 2012 02:14, Steven D'Aprano
>> <steve+comp.lang.python@pearwood.info> wrote:
>>>
>>> On Wed, 12 Sep 2012 08:52:10 +1000, Chris Angelico wrote:
>>>
>>> > Inline functions? I like this idea. I tend to want them in pretty much
>>> > any language I write in.
>>>
>>> What do you mean by in-line functions? If you mean what you literally
>>> say, I would answer that Python has that with lambda.
>>>
>>> But I guess you probably mean something more like macros.
>>
>> No, just multi-line lambda. Macros, if my knowledge of lower-level
>> languages
>> is valid, would be sorta' silly in Python.
>
> Ah, okay. I was thinking more along the lines of what you call macros,
> but in the C++ sense of inline functions. In C, macros are handled at
> precompilation stage, and are dangerous. Classic example:
>
> #define squared(x) x*x
>
> x_squared = squared(6+7)
>
> So your macros end up littered with parentheses, and it still doesn't
> solve anything, as the argument still gets evaluated twice. (A problem
> if it has side effects - eg if it's a function call.)
>
> What I'm thinking of, though, is like C++ functions. You can put the
> 'inline' keyword onto any function, and the compiler will do its best
> to inline it (in fact, a good optimizing compiler will inline things
> regardless, but that's a separate point). I can write:
>
> inline int squared(int x) {return x*x;}
>
> and C++ will add no function overhead, but will still do all the
> proper evaluation order etc.
>
> Of course, C++ doesn't allow monkeypatching, so you'll never have
> semantic differences from inlining. It's just a performance question.
> But I use inline functions like constants - for instance, I could
> create a function that converts a database ID into an internal
> reference number, and I can change the definition of that function in
> one place and have it apply everywhere, just like if I wanted to
> change the definition of math.PI to 3.142857 for fun one day. Of
> course I can use a normal (out-of-line) function for this, but that
> has overhead in most languages. Hence, wanting inline functions.
Interesting. I'd overestimated macros and underestimated inline functions.
I am not sure how to make a version of that with scope-compatibility. Inlining
inline_def f(y): x = y +1
would hopefully not change the outside scope*, but I'm not sure how to
make that.
I could make it work by banning "=", but then it's almost a macro but with
internal_a = input_a
internal_b = input_b
...
at the start...
* If I understand rightly
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Double sided double underscored variable names Chris Angelico <rosuav@gmail.com> - 2012-09-12 08:52 +1000
Re: Double sided double underscored variable names Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-12 01:14 +0000
Re: Double sided double underscored variable names Chris Angelico <rosuav@gmail.com> - 2012-09-12 14:12 +1000
Re: Double sided double underscored variable names Joshua Landau <joshua.landau.ws@gmail.com> - 2012-09-12 10:55 +0100
csiph-web