[Python-Dev] datetime nanosecond support (ctd?)

Matthieu Bec mbec at gmto.org
Wed Dec 17 00:28:32 CET 2014


Maybe what I meant with `nothing looks quite right':
seconds as float, microseconds as float, nanosecond as 0..999, 
nanoseconds as 0..999999999 with mandatory keyword that precludes 
microseconds - all can be made to work, none seems completely satisfying.

In fact, I don't really have a use for it from python - but something 
would be needed in C for the implementation of datetime.from_timespec 
and time.from_timespec that calls the constructor 
PyObjectCall_CallFunction(clas,"...",...) - can this happen and remain 
hidden from the python layer?

Regards,
Matthieu



On 12/16/14 12:45 PM, Alexander Belopolsky wrote:
>
> On Tue, Dec 16, 2014 at 12:10 PM, matthieu bec <mbec at gmto.org
> <mailto:mbec at gmto.org>> wrote:
>
>     I wonder if the datetime module is really the right location, that
>     has constructor(year, month, day, ..., second, microsecond) - with
>     0<ms<999999, no millis. adding 0<ns<999 would seem quite ugly, in
>     fact nothing looks quite right.
>
>
> We can make nanosecond a keyword-only argument, so that
>
> time(1, 2, 3, nanosecond=123456789) -> 01:02:03.123456789
>
> and
>
> time(1, 2, 3, 4, nanosecond=123456789) -> error
>
> Users will probably be encouraged to avoid positional form when
> specifying time to subsecond precision.  I would say  time(1, 2, 3,
> microsecond=4) is clearer than time(1, 2, 3, 4) anyways.
>
> Another option is to allow float for the "second" argument:
>
> time(1, 2, 3.123456789) -> 01:02:03.123456789
>
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/mdcb808%40gmail.com
>

-- 
Matthieu Bec                GMTO Corp
cell : +1 626 425 7923      251 S Lake Ave, Suite 300
phone: +1 626 204 0527      Pasadena, CA 91101


More information about the Python-Dev mailing list