Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86718
| Subject | Re: Design thought for callbacks |
|---|---|
| From | Cem Karan <cfkaran2@gmail.com> |
| Date | 2015-03-02 06:11 -0500 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.26.1425294728.13471.python-list@python.org> (permalink) |
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
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-03-02 06:11 -0500
csiph-web