Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105375
| Path | csiph.com!news.mixmin.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Static caching property |
| Date | Mon, 21 Mar 2016 17:03:49 +0000 |
| Lines | 18 |
| Message-ID | <mailman.449.1458579835.12893.python-list@python.org> (permalink) |
| References | <35a5c4206a0c40e584d62d5d37b068b3@activenetwerx.com> <mailman.446.1458576961.12893.python-list@python.org> <56f0230e$0$1616$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqvu4qMpcbR-g5QZG6neuJVcHrKLYLDFe5QC_QBQbd2-g@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="iso-8859-1" |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de c5OAzOPxdQE07rRJydU/Eg/Amh0ifWndjBvHTfF7ez3g== |
| Return-Path | <jcasale@activenetwerx.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'none:': 0.05; 'option,': 0.07; '@property': 0.09; 'descriptor': 0.09; 'def': 0.13; 'chris,': 0.16; 'complicating': 0.16; 'received:172.18.0': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:name:python- list@python.org': 0.20; 'class,': 0.22; 'import': 0.24; 'header :In-Reply-To:1': 0.24; 'wonder': 0.27; "i'm": 0.30; 'class': 0.33; 'option.': 0.33; 'that,': 0.34; 'protocol': 0.35; 'something': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'means': 0.39; 'test': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'cheap...': 0.84 |
| X-Authority-Analysis | v=2.1 cv=VIR9547X c=1 sm=1 tr=0 a=g3mLq75WYuDrh3Lt0JSDww==:117 a=g3mLq75WYuDrh3Lt0JSDww==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=P90J6pEA2ccA:10 a=8nJEP1OIZ-IA:10 a=7OsogOcEt9IA:10 a=eqQ5kIR8T3PH-21IvCoA:9 a=wPNLvfGTeEIA:10 |
| X-Spam-Checker-Version | SpamAssassin 3.4.0 (2014-02-07) on mail.activenetwerx.com |
| X-Spam-Level | |
| X-Spam-Status | No, score=-1.0 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.0 |
| Thread-Topic | Static caching property |
| Thread-Index | AQHRg4dpC97vHCaJwEm/OBao3y7fUJ9kGfXygAAA4OmAAGdfAP//nRpr |
| In-Reply-To | <CAPTjJmqvu4qMpcbR-g5QZG6neuJVcHrKLYLDFe5QC_QBQbd2-g@mail.gmail.com> |
| Accept-Language | en-CA, en-US |
| Content-Language | en-CA |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [172.18.0.4] |
| X-CMAE-Envelope | MS4wfDMcIJd+z3yUkLt5djeLHeCtytYMJSXwYsmeAd6i44QOHVexPdxgCa8OeyvA5y4pDvfjR9ZRwvt1me3JL4BEtNIz1VFtd4UqHQUYywGRLwNcuHCud+CI khpMbOToUcBncEBjFacqG1mB7j4KfnAAACXDcfXx+yUUEh76+oWhMsvNDp6kepeayQJfEaOYINJx9w== |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105375 |
Show key headers only | View raw
> One solution is to use descriptor protocol on the class, which means
> using a metaclass. I'm not sure it's the best option, but it is an
> option.
I will look at that, I wonder if however I am not over complicating it:
class Foo:
_bar = None
@property
def expensive(self):
if Foo._bar is None:
import something
Foo._bar = something.expensive()
return Foo._bar
Somewhat naive, but a test with if is pretty cheap...
Thanks Chris,
jlc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Static caching property Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-21 10:15 -0600
Re: Static caching property Steven D'Aprano <steve@pearwood.info> - 2016-03-22 03:36 +1100
Re: Static caching property "Joseph L. Casale" <jcasale@activenetwerx.com> - 2016-03-21 16:49 +0000
Re: Static caching property Chris Angelico <rosuav@gmail.com> - 2016-03-22 03:54 +1100
Re: Static caching property "Joseph L. Casale" <jcasale@activenetwerx.com> - 2016-03-21 17:03 +0000
Re: Static caching property Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-21 11:44 -0600
Re: Static caching property Ethan Furman <ethan@stoneleaf.us> - 2016-03-21 10:45 -0700
Re: Static caching property Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-21 11:48 -0600
Re: Static caching property Steven D'Aprano <steve@pearwood.info> - 2016-03-22 11:05 +1100
Re: Static caching property Chris Angelico <rosuav@gmail.com> - 2016-03-22 11:15 +1100
Re: Static caching property Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-22 07:30 -0600
csiph-web