From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: How to canonicalize a time object
Date: Sun, 14 Aug 2022 13:15:27 -0400 [thread overview]
Message-ID: <jwvtu6en5dt.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <877d3ahlxi.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 14 Aug 2022 17:41:45 +0200")
Lars Ingebrigtsen [2022-08-14 17:41:45] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> What's the best way in ELisp to turn an arbitrary time value into one
>> that will be as efficient as possible for `lisp_time_argument`?
> I'm not quite sure I understand the question -- the `t' type for
> `time-convert' is supposed to be the most efficient representation of an
> arbitrary time value,
Yes, it seems that using the representation returned by `time-convert`
when you ask for the `t` form is the "most efficient" for some
definition of it, but I'm specifically interested in the efficiency of
passing the result to `lisp_time_argument`: that function uses
`lisp_to_timespec` which has various "fast paths" and I'm not sure how
to make sure we'll go through them. E.g. if we do (time-convert FLOAT t)
the returned value will be of the form (TICKS . 2^51) and for
(time-convert (HI LOW US) t) it'll be (TICKS . 10^6), but
`lisp_to_timespec` doesn't seem to have a fast path for 2^51 and I'm not
sure it has one for 10^6 (nor 10^12 used for (HI LOW US PS)).
It appears that the best choice currently is to use `timespec_hz`
(or 1 if the time is a whole number of seconds), but:
- There doesn't seem to be an easy way to get `timespec_hz` from ELisp.
- It's cumbersome to find out if a time value is a whole number
of seconds.
- It's not very elegant to have ELisp code do such gymnastics which
depend on the presence/absence of specific fast-paths in the C code,
which my also change in the future.
> but if you don't have sub-second resolution to your time, the
> `integer' one is probably more efficient?
Indeed, tho only for that specific situation :-(
Of course, maybe we shouldn't care, and just presume that the slow path
which does a GMP mul+div is plenty fast anyway.
Stefan
next prev parent reply other threads:[~2022-08-14 17:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-05 16:24 How to canonicalize a time object Stefan Monnier
2022-08-13 22:01 ` Stefan Monnier
2022-08-14 15:41 ` Lars Ingebrigtsen
2022-08-14 17:15 ` Stefan Monnier [this message]
2022-08-14 21:17 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvtu6en5dt.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).