On 03Apr2012 09:07, Ethan Furman <et...@stoneleaf.us> wrote:
| Lennart Regebro wrote:
| > On Tue, Apr 3, 2012 at 08:03, Cameron Simpson <c...@zip.com.au> wrote:
| >>  clock = get_clock(MONOTONIC|HIRES) or get_clock(MONOTONIC)
| >>
| >> If the symbol names are not the horribleness, can you qualify what API
| >> you would like more?
| > 
| > Well, get_clock(monotonic=True, highres=True) would be a vast
| > improvement over get_clock(MONOTONIC|HIRES).
| 
| Allowing get_clock(True, True)?  Ick.  My nomination would be
| get_clock(MONOTONIC, HIGHRES) -- easier on the eyes with no |.

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

Have a quick glance at:

  https://bitbucket.org/cameron_simpson/css/src/tip/lib/python/cs/clockutils.py

(I finally found out how to point at the latest revision on BitBucket;
it's not obvious from the web interface itself.)

| > I also think it should
| > raise an error if not found. The clarity and easy of use of the API is
| > much more important than how much you can do in one line.

How much you can do _clearly_ in one line is a useful metric.

| What's unclear about returning None if no clocks match?

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)

seems to satisfy both these criteria to my eye. Raising an exception
makes user fallback a royal PITA, with a horrible try/except cascade
needed.

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.

Cheers,
-- 
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Because of its special customs, crossposting between alt.peeves and normal
newsgroups is discouraged.      - Cameron Spitzer
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to