Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev
Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock)
 

Index | Next | Previous | View Flat


ethan at stoneleaf

Apr 3, 2012, 3:08 PM


Views: 460
Permalink
Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) [In reply to]

Cameron Simpson wrote:
> get_clock already has two arguments - you can optionally hand it a clock
> list - that's used by monotonic_clock() and hires_clock().

def get_clock(*flags, *, clocklist=None):
''' Return a Clock based on the supplied `flags`.
The returned clock shall have all the requested flags.
If no clock matches, return None.
'''
wanted = 0
for flag in flags:
wanted |= flag
if clocklist is None:
clocklist = ALL_CLOCKS
for clock in clocklist:
if clock.flags & wanted == wanted:
return clock.factory()
return None

Would need to make *flags change to the other *_clock functions.


> Have a quick glance at:
>
> https://bitbucket.org/cameron_simpson/css/src/tip/lib/python/cs/clockutils.py

Thanks.


> The return of None is very deliberate. I _want_ user specified fallback
> to be concise and easy. The example:
>
> clock = get_clock(MONOTONIC|HIRES) or get_clock(MONOTONIC)

Which would become:

clock = get_clock(MONOTONIC, HIGHRES) or get_clock(MONOTONIC)

+1 to returning None


> Exceptions are all very well when there is just one thing to do: parse
> this or fail, divide this by that or fail. If fact they're the very
> image of "do this one thing or FAIL". They are not such a good match for do
> this thing or that thing or this other thing.
>
> When you want a simple linear cascade of choices, Python's short circuiting
> "or" operator is a very useful thing. Having an obsession with exceptions is
> IMO unhealthy.

Another +1.

~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Subject User Time
an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 1, 2012, 5:43 PM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) victor.stinner at gmail Apr 2, 2012, 4:37 AM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 2, 2012, 2:38 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 2, 2012, 2:51 PM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 2, 2012, 3:05 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 2, 2012, 3:44 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) regebro at gmail Apr 2, 2012, 10:51 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) victor.stinner at gmail Apr 3, 2012, 4:45 PM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 2, 2012, 11:03 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) breamoreboy at yahoo Apr 3, 2012, 1:03 AM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 3, 2012, 1:43 AM
                Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) greg.ewing at canterbury Apr 3, 2012, 5:04 PM
                    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) breamoreboy at yahoo Apr 3, 2012, 5:18 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) regebro at gmail Apr 3, 2012, 7:09 AM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 3, 2012, 9:07 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 3, 2012, 2:42 PM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 3, 2012, 3:08 PM
                Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 3, 2012, 4:38 PM
                    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ncoghlan at gmail Apr 3, 2012, 4:46 PM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) regebro at gmail Apr 4, 2012, 8:47 AM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 3, 2012, 7:46 PM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) p.f.moore at gmail Apr 4, 2012, 1:21 AM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 4, 2012, 9:18 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) g.brandl at gmx Apr 4, 2012, 10:47 AM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 4, 2012, 11:06 AM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 4, 2012, 3:06 PM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 4, 2012, 10:44 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 4, 2012, 11:03 AM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 4, 2012, 12:24 PM
                Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 4, 2012, 12:52 PM
                    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 4, 2012, 4:05 PM
                        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) stephen at xemacs Apr 5, 2012, 6:06 AM
                        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 5, 2012, 11:56 AM
                            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 5, 2012, 1:15 PM
                                Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) ethan at stoneleaf Apr 5, 2012, 1:49 PM
                                Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 5, 2012, 3:08 PM
                        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) cs at zip Apr 5, 2012, 3:05 PM
                Re: an alternative to embedding policy in PEP 418 steve at pearwood Apr 4, 2012, 3:50 PM
                    Re: an alternative to embedding policy in PEP 418 cs at zip Apr 4, 2012, 4:14 PM
                        Re: an alternative to embedding policy in PEP 418 steve at pearwood Apr 6, 2012, 3:25 AM
                            Re: an alternative to embedding policy in PEP 418 cs at zip Apr 6, 2012, 4:11 PM
                                Re: an alternative to embedding policy in PEP 418 v+python at g Apr 6, 2012, 5:30 PM
                                    Re: an alternative to embedding policy in PEP 418 cs at zip Apr 6, 2012, 9:22 PM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 5, 2012, 6:34 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) stephen at xemacs Apr 5, 2012, 7:45 AM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 5, 2012, 8:22 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) rdmurray at bitdance Apr 5, 2012, 8:38 AM
            Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 5, 2012, 9:02 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) phd at phdru Apr 5, 2012, 9:01 AM
        Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) stephen at xemacs Apr 5, 2012, 7:57 PM
    Re: an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock) murman at gmail Apr 6, 2012, 4:31 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.