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


Groups > comp.lang.python > #86718

Re: Design thought for callbacks

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cfkaran2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.036
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'falls': 0.09; 'references,': 0.09; 'url:github': 0.09; 'api': 0.11; 'cc:addr :python-list': 0.11; '(note': 0.16; '24,': 0.16; 'closures,': 0.16; 'fabio': 0.16; 'illustrate': 0.16; 'posting,': 0.16; 'thread,': 0.16; 'top-level': 0.16; 'url:py': 0.16; 'url:pydev': 0.16; 'exception': 0.16; 'url:)': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; '(not': 0.18; 'wed,': 0.18; 'bit': 0.19; '(where': 0.19; 'everyone,': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'stick': 0.24; 'url:02': 0.24; 'earlier': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'references': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'related': 0.29; "i'm": 0.30; 'code': 0.31; 'posting': 0.31; 'usually': 0.31; '(on': 0.31; '25,': 0.31; 'handled': 0.32; 'quite': 0.32; "i'd": 0.34; 'agree': 0.35; 'created': 0.35; 'late': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; "didn't": 0.36; "i'll": 0.36; 'possible': 0.36; 'similar': 0.36; 'should': 0.36; 'so,': 0.37; 'list': 0.37; 'list.': 0.37; 'being': 0.38; 'sometimes': 0.38; 'message- id:@gmail.com': 0.38; 'thank': 0.38; 'planning': 0.38; 'pm,': 0.38; 'expect': 0.39; 'though,': 0.39; 'how': 0.40; 'days': 0.60; 'read': 0.60; 'manually': 0.60; 'mentioned': 0.61; 'simple': 0.61; 'back': 0.62; 'header:Message-Id:1': 0.63; 'decided': 0.64; 'different': 0.65; 'url:blogspot': 0.65; 'to:addr:gmail.com': 0.65; 'license': 0.66; 'worth': 0.66; '26,': 0.68; 'url:br': 0.69; 'subject:Design': 0.78; '2015': 0.84; 'come,': 0.84; 'everywhere.': 0.84; 'subject:thought': 0.84; 'url:master': 0.84; 'convinced': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZraZul/pGxpmLgsO8AMEUobIegb7TQlYyS5XQ0C0czc=; b=PaJMgAUHzou1Q8iSJ/k4KWwh+4i97czvXtQm2PS8iwQhuC8r1B5W21o7a8VDMPZn04 FflBWnGwp4HaUDLsfh0eYy9MYFmnBmhEJwZRDozIHPsYPg9ck7dMiBn6mvgk502sx5mt KTBof3Oyz/R8ARJu6p1ydDcZV7w+zk0N0aP2V6TIhgWBEJeO6GlurcEkJfPG3yLim3kK oKVz3iLCQG3x1A3twbcVfsn6vxgJC4nBXA9eEWz9HNpk/+Iyhc995evpAGOXQxP614hQ XYiUXkxktglX0kAQw2qjZKfqR+mjkJhuTGGjY0b+U/p4AeCpnxuBOpadyTBrVZYebv5L 7TNQ==
X-Received by 10.55.42.41 with SMTP id q41mr5491145qkh.15.1425294720383; Mon, 02 Mar 2015 03:12:00 -0800 (PST)
Content-Type text/plain; charset=utf-8
Mime-Version 1.0 (Mac OS X Mail 6.6 \(1510\))
Subject Re: Design thought for callbacks
From Cem Karan <cfkaran2@gmail.com>
In-Reply-To <CANXBEFpmL6yQcKvYLrCbFhGM++VVPSwoW+oj+j8STF5qJJSAXg@mail.gmail.com>
Date Mon, 2 Mar 2015 06:11:59 -0500
Cc "comp.lang.python" <python-list@python.org>
Content-Transfer-Encoding quoted-printable
References <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <CANXBEFq6dbJ-J7j4QaiR=d0pD6PfM9nsNpxYEeJ4D_vabEuucw@mail.gmail.com> <575FE33B-D1AD-4391-B816-7440D5849C41@gmail.com> <CANXBEFpmL6yQcKvYLrCbFhGM++VVPSwoW+oj+j8STF5qJJSAXg@mail.gmail.com>
To Fabio Zadrozny <fabiofz@gmail.com>
X-Mailer Apple Mail (2.1510)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
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>
Newsgroups comp.lang.python
Message-ID <mailman.26.1425294728.13471.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425294728 news.xs4all.nl 2856 [2001:888:2000:d::a6]:48906
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86718

Show key headers only | View raw


On Feb 26, 2015, at 7:04 PM, Fabio Zadrozny <fabiofz@gmail.com> wrote:

> 
> On Wed, Feb 25, 2015 at 9:46 AM, Cem Karan <cfkaran2@gmail.com> wrote:
> 
> On Feb 24, 2015, at 8:23 AM, Fabio Zadrozny <fabiofz@gmail.com> wrote:
> 
> > Hi Cem,
> >
> > I didn't read the whole long thread, but I thought I'd point you to what I'm using in PyVmMonitor (http://www.pyvmmonitor.com/) -- which may already cover your use-case.
> >
> > Take a look at the callback.py at https://github.com/fabioz/pyvmmonitor-core/blob/master/pyvmmonitor_core/callback.py
> >
> > And its related test (where you can see how to use it): https://github.com/fabioz/pyvmmonitor-core/blob/master/_pyvmmonitor_core_tests/test_callback.py (note that it falls back to a strong reference on simple functions -- i.e.: usually top-level methods or methods created inside a scope -- but otherwise uses weak references).
> 
> That looks like a better version of what I was thinking about originally.  However, various people on the list have convinced me to stick with strong references everywhere.  I'm working out a possible API right now, once I have some code that I can use to illustrate what I'm thinking to everyone, I'll post it to the list.
> 
> Thank you for showing me your code though, it is clever!
> 
> Thanks,
> Cem Karan
> 
> ​Hi Cem,
> 
> Well, I decided to elaborate a bit on the use-case I have and how I use it (on a higher level): http://pydev.blogspot.com.br/2015/02/design-for-client-side-applications-in.html
> 
> So, you can see if it may be worth for you or not (I agree that sometimes you should keep strong references, but for my use-cases, weak references usually work better -- with the only exception being closures, which is handled different anyways but with the gotcha of having to manually unregister it).

As I mentioned in an earlier post, I've been quite busy at home, and expect to be for a few days to come, so I apologize both for being so late posting, and for not posting my own API plans.

Your blog post has given me quite a bit to think about, thank you!  Do you mind if I work up an API similar to yours?  I'm planning on using a different license (not LGPL), which is why I ask.

Thanks,
Cem Karan

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


Thread

Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-03-02 06:11 -0500

csiph-web