Vincenzo Ampolo <vincenzo.amp...@gmail.com> added the comment: On 07/24/2012 01:28 PM, Marc-Andre Lemburg wrote: > I would be interested in an actual use case for this.
Alice has a dataset with nanosecond granularity. He wants to make a python library to let Bob access the dataset. Nowadays Alice has to implement her own time class losing all the flexibility of the datetime module. With this enhancement she can provide a library that just uses the standard python datetime module. Her library will get the needed time format, including nanoseconds. Many python sql libraries, like the one in django e the one in web2py, relay on datetime objects for time representation. Bob has a web2py website that has some data with nanosecond granularity. Nowadays Bob has to store this data as a string or a long number without the ability to use the powerful datetime module. With this enhancement Bob doesn't need to build or learn another interface, he can just use the datetime module using microseconds or nanoseconds as needed. Google search for "python datetime nanoseconds" shows more than 141k results: https://www.google.com/search?sourceid=chrome&ie=UTF-8&q=python+time#hl=en&biw=1615&bih=938&sclient=psy-ab&q=python+datetime+nanoseconds&oq=python+datetime+nanoseconds So this is definitively a requested feature. And as soon as technology evolves more people will ask for it. I imagine something like: import datetime nano_time = datetime.datetime(year=2012, month=07, day=24, hour=14, minute=35, second=3, microsecond=53, nanosecond=27) in case you need nanosecond granularity. if you don't need it just skip the nanosecond part and the module works like it's now. Of course strftime format should be updated to support nanoseconds. I can write a patch if some dev can maybe review it. Before someone takes the datetime source code and starts a third part module that supports nanoseconds, I think this enhancement has almost null impact in existing code and makes the datetime module even more powerful. It's up to the Cpython admins to decide between maintaining datetime module up to date with new needs or let third part modules take care of those lacks. Best Regards, -- Vincenzo Ampolo http://vincenzo-ampolo.net http://goshawknest.wordpress.com ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15443> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com