Re: [Python-Dev] datetime and timedelta enhancement

2008-11-15 Thread M.-A. Lemburg
On 2008-11-14 23:59, Victor Stinner wrote:
> Hi,
> 
> There are some interresting tickets about the datetime module:
> #1673409: datetime module missing some important methods
> #1083: Confusing error message when dividing timedelta using /
> #2706: datetime: define division timedelta/timedelta
> #4291: Allow Division of datetime.timedelta Objects
> 
> Wanted features:
> 1- convert a datetime object to an epoch value (numbers of seconds since 
>the 1st january 1970), eg. with a new totimestamp() method
> 2- convert a timedelta to a specific unit (eg. seconds, days, weeks, etc.)
> 3- compute the ratio of two timedelta, eg. for a progress bar

Since the datetime module turned out to be mostly a reimplementation
of mxDateTime, why not continue down that road ?

http://www.egenix.com/products/python/mxBase/mxDateTime/

Let's see:

>>> from mx.DateTime import *

>>> DateTime(2008,11,15).ticks()
1226703600.0

>>> TimeDelta(seconds=100)


>>> TimeDelta(seconds=100) / TimeDelta(seconds=50)
2.0

>>> TimeDelta(seconds=100).seconds
100.0

>>> TimeDelta(seconds=100).days
0.0011574074074074073

>>> TimeDelta(seconds=100).weeks
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: weeks

Guess I could add a .weeks attribute to mxDateTime, but no one ever
asked for that so far.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 15 2008)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2008-11-12: Released mxODBC.Connect 0.9.3  http://python.egenix.com/

 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
___
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


Re: [Python-Dev] Optionally using GMP to implement long if available

2008-11-15 Thread Gregory P. Smith
On Tue, Nov 4, 2008 at 10:33 AM, Tim Peters <[EMAIL PROTECTED]> wrote:
>
> 2. On platforms that support it, this is at least 64x64->64 multiplication,
>   potentially much more expensive than the 32x32->64 (or 31x31->62?)
>   flavor you /intend/ to move to.

Thats a good point, thanks!

I am not averse to including a tiny bit of platform (i386) specific
inline asm (in its own header file as a macro to make it easy to
maintain and easy to turn off and easy to add versions for someone
elses favorite 32bit platform) to get that when compiled to use 30bit
digits since the C language has no way to express it directly.

-gps
___
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


Re: [Python-Dev] datetime and timedelta enhancement

2008-11-15 Thread Nick Coghlan
M.-A. Lemburg wrote:
> Guess I could add a .weeks attribute to mxDateTime, but no one ever
> asked for that so far.

Given that there are at least 3 different ways to define the number of
"weeks" between two dates, it may be something best left to applications
to worry about.

OOo implements 2 of them [1] for its WEEKS() function, and there's then
a fairly obvious 3rd variant based on a Sunday to Saturday week.

Cheers,
Nick.

[1]
http://wiki.services.openoffice.org/wiki/Documentation/How_Tos/Calc:_WEEKS_function



-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
___
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


[Python-Dev] Summaries for Number 2008, First Half

2008-11-15 Thread Calvin Spealman
Wow, how long has this been? OK, so these aren't really the summaries.
It is half-done summaries, which I've posted to the wiki for community
collaboration. Anyone with a better understanding a conversation or
simply the knowledge that I don't know what I'm talking about half the
time, the summary can be edited easily now. I'd like to try a schedule
of posting the draft to the wiki, leaving it up for edits for two
weeks, and publishing the final summaries when the next summary draft
is prepared and put up for review. Does that sound like a decent plan
that might actually see the return of the summaries be stuck with?

The draft is at
http://wiki.python.org/moin/PyDevSummaries/2008/November/FirstHalf

Of course, if you don't have time to edit this but do want to make any
comments, suggestions, or corrections, or you want to suggest that any
thread should be promoted from the bottom list or demoted down to it,
just let me know. And the current draft is found below.

=
Announcements
=

This is the draft of the python-dev mailing list summaries for the
first half of November 2008. Please make any corrections,
improvements, or comments. The contents will be finalized at the end
of the month, when the summaries' draft for the second half of
November 2008 are posted. I hope to keep this schedule regularly.

=
Summaries
=

---
Looking for VCS usage scenarios
---

Brett Cannon solicits any use cases and scenarios that would give an
understanding for the motivations in proposing Python move to or
mirror officially via some distributed version control. Much
discussion ensued that I didn't have the time to follow. This thread
was over 100 posts, so anyone who followed it well, please give as
concise an overview as you can.

Contributing thread:

- `Looking for VCS usage scenarios
`__

---
Optionally using GMP to implement long if available
---

The suggestion of using the GMP library to implement Python's long
numbers was brought in the context of an compile time option, falling
back to the current in-house implementation when GMP is not available.
However, the discussion points out that most distribution of Python is
binary and so the LGPL issues that keep us from using GMP still apply.

Some of the conversation also suggestion various improvements to our
own implementation, mostly focused on increasing size of the base long
values are stored in, particularly on 64bit systems.

Contributing thread:

- `Optionally using GMP to implement long if available
`__


Fwd: Removal of GIL through refcounting removal.


Yet Another Attempt At Removing The GIL was proposed, and had a more
positive reception than most of the times it has been brought up (in
my memory). While the removal of the GIL has been both proposed and
successfully attempted in the past, there have always been outstanding
issues that keep the lock around. One of the primary issues is that of
the C API and extension modules, which all expect reference counting.
A technique used in IronClad, a project that provides use of CPython
extensions in the IronPython implementation of the language, was
suggested to provide reference counting semantics to legacy
extensions, even if the internal objects no longer require them.

Contributing thread:

- `Fwd: Removal of GIL through refcounting removal.
`__

--
Using Cython for standard library?
--

Without much expectation that any action will actually be taken any
time soon, the possibility of using Cython (and, by extension, similar
solutions) was given consideration. While the benefits of these
solutions are obvious, there is no particular best of breed nor yet a
point of stability that a mature project might stand on. It would be
exciting to one day see some variation of this happen, but that day is
not today.

Contributing thread:

- `Using Cython for standard library?
`__

--
n.numbits: method or property?
--

The basic question of a proposed method or property, numbits, drew
into a small discussion about the inherent assumption of binary
representation of our numbers. The numbits method or property would
provide the smallest number of bits required to represent a given
integer.

Contributing thread:

- `n.numbits: method or property?
`__