Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread M.-A. Lemburg
n 31.03.2014 21:09, Chris Barker wrote:
 On Fri, Mar 28, 2014 at 2:52 PM, Fred Drake f...@fdrake.net wrote:
 
 On Fri, Mar 28, 2014 at 5:19 PM, Greg Ewing greg.ew...@canterbury.ac.nz
 wrote:
 ISO 8601 doesn't seem to define a representation for
 negative durations, though, so it wouldn't solve the
 original problem.

 Aside from the horribleness of the ISO 8601 notation for a duration, it's
 best not to confuse the notions of duration and delta.  Notionally, a delta
 contains more information than a duration.
 
 
 and less -- really it's different.
 
 A duration would be really useful actually, for things like next month,
 etc,. IIRC, mxDateTime has something for this, but it's NOT the same as a
 timedelta.

mxDateTime has DateTimeDelta objects which represent a time delta
(in the mathematical sense) between two points in DateTime and
RelativeDateTime objects which allow defining deltas in terms
of qualifiers which are applied to the left hand side of an operation.

With RelativeDateTime you can do things like e.g.

first_of_next_month = now() + RelativeDateTime(months=+1, day=1)

There are some other concepts you can emulate with these, like e.g.
a specific time frame (DateTime + one of the above deltas), a
reoccurring time (start_time + one of the deltas + number
occurrences + exceptions), an age concept (difference between two
DateTime values expressed in RelativeDateTime terms), etc.

Some examples:

 from mx.DateTime import *

 print RelativeDateTime(months=+1, day=1)
-(+01)-01 HH:MM:SS

 print now() + RelativeDateTime(months=+1, day=1)
2014-05-01 14:49:05.83

 print Age(now(), Date(1969,4,6))
(+0044)-(+11)-(+27) (+14):(+49):(+02)

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 02 2014)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2014-04-09: PyCon 2014, Montreal, Canada ...7 days to go
2014-04-29: Python Meeting Duesseldorf ... 27 days to go

: Try our mxODBC.Connect Python Database Interface 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
   http://www.egenix.com/company/contact/
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread Skip Montanaro
On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg m...@egenix.com wrote:
  print now() + RelativeDateTime(months=+1, day=1)
 2014-05-01 14:49:05.83

I find this sort date arithmetic unintuitive, though I'm at a loss to
come up with better logic than you have:

 d = Date(2014, 2, 28)
 d + RelativeDateTime(months=+1)
mx.DateTime.DateTime object for '2014-03-28 00:00:00.00' at 1eda8c8
 d = Date(2014, 1, 31)
 d + RelativeDateTime(months=+1)
mx.DateTime.DateTime object for '2014-03-03 00:00:00.00' at 1eda870

I guess the assumption is that one month is the length in days of the
current month, though, you wind up with situations where shorter
months can be skipped altogether. Is there a way to talk in terms of
months but not have short months get skipped?

Thx,

Skip
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread Xavier Morel

On 2014-04-02, at 15:04 , Skip Montanaro s...@pobox.com wrote:

 On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg m...@egenix.com wrote:
 print now() + RelativeDateTime(months=+1, day=1)
 2014-05-01 14:49:05.83
 
 I find this sort date arithmetic unintuitive, though I'm at a loss to
 come up with better logic than you have:
 
 d = Date(2014, 2, 28)
 d + RelativeDateTime(months=+1)
 mx.DateTime.DateTime object for '2014-03-28 00:00:00.00' at 1eda8c8
 d = Date(2014, 1, 31)
 d + RelativeDateTime(months=+1)
 mx.DateTime.DateTime object for '2014-03-03 00:00:00.00' at 1eda870
 
 I guess the assumption is that one month is the length in days of the
 current month, though, you wind up with situations where shorter
 months can be skipped altogether. Is there a way to talk in terms of
 months but not have short months get skipped?

FWIW dateutil has a slightly different logic there:

 date(2014, 2, 28) + relativedelta(months=+1)
datetime.date(2014, 3, 28)
 date(2014, 1, 31) + relativedelta(months=+1)
datetime.date(2014, 2, 28)

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread M.-A. Lemburg
On 02.04.2014 15:04, Skip Montanaro wrote:
 On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg m...@egenix.com wrote:
 print now() + RelativeDateTime(months=+1, day=1)
 2014-05-01 14:49:05.83
 
 I find this sort date arithmetic unintuitive, though I'm at a loss to
 come up with better logic than you have:
 
 d = Date(2014, 2, 28)
 d + RelativeDateTime(months=+1)
 mx.DateTime.DateTime object for '2014-03-28 00:00:00.00' at 1eda8c8
 d = Date(2014, 1, 31)
 d + RelativeDateTime(months=+1)
 mx.DateTime.DateTime object for '2014-03-03 00:00:00.00' at 1eda870
 
 I guess the assumption is that one month is the length in days of the
 current month, though, you wind up with situations where shorter
 months can be skipped altogether. Is there a way to talk in terms of
 months but not have short months get skipped?

I'm not really satisfied with this solution either.

The problem is that the qualifier + 1 month is not defined for
dates with don't have a corresponding day in the following month.

This should probably either raise an exception or use some
parameter to solve the problem, by e.g. choosing the last day
of the month or using the current scheme:

mxDateTime skips to the first of the next month and then advances
the number of days defined in the left hand DateTime value,
i.e. Date(2014, 2, 1) + 30 * oneDay.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 02 2014)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2014-04-09: PyCon 2014, Montreal, Canada ...7 days to go
2014-04-29: Python Meeting Duesseldorf ... 27 days to go

: Try our mxODBC.Connect Python Database Interface 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
   http://www.egenix.com/company/contact/
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] libpython added to ABI tracker

2014-04-02 Thread Andrey Ponomarenko


Nick Coghlan wrote:

Regarding the warnings for this one - is there a way for the checker
to warn if data structures are exposed directly, rather than as opaque
types? It's fine if there isn't, it would just be cool if there was -
one of the premises of the stable ABI is that it *doesn't* expose the
type definitions directly to consuming code, just the pointers to them
(hence allowing the struct size to change without actually breaking
compatibility with the defined ABI).


The ABI of the library can be dumped by the abi-compliance-checker basic 
tool to a text file in the human readable format, so anyone can analyse 
it in order to find problems of any kind.


Homepage of the tool: https://github.com/lvc/abi-compliance-checker

To dump the libpython ABI type:

$ abi-compliance-checker -l libpython -dump descriptor.xml

The descriptor.xml input file ({RELPATH} - path to the python install 
tree, i.e. installation prefix):


version
3.4.0
/version

headers
{RELPATH}/include
/headers

libs
{RELPATH}/lib/libpython3.4m.so.1.0
/libs

skip_including
ast.h
Python-ast.h
asdl.h
pyexpat.h
pymactoolbox.h
/skip_including

gcc_options
-DPy_LIMITED_API=0x0302
/gcc_options

I've already created the sample dump of the libpython-3.4.0 stable ABI 
here: http://upstream-tracker.org/downloads/libpython_3.4.0.abi.tar.gz


In order to analyse data types in the ABI please read 'TypeInfo' section 
of the dump.


I see several structures with exposed definition in the stable ABI v3.4.0:

struct PyStructSequence_Desc
struct grammar
struct PyStructSequence_Field
struct _node
struct cchar_t
struct PyType_Spec
struct PyType_Slot
struct dfa
struct labellist
struct PyMethodDef
struct _Py_Identifier
struct state
struct PyVarObject
struct arc
struct label
struct PyModuleDef
struct PyModuleDef_Base
struct PyMemberDef
struct PyGetSetDef
struct _object
struct PyCursesWindowObject


Thanks.

--
Andrey Ponomarenko, NTC IT ROSA.

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] libpython added to ABI tracker

2014-04-02 Thread Martin v. Löwis
Am 01.04.14 13:45, schrieb Nick Coghlan:
 Interesting to see the UCS2 removal there for 3.3. That's a genuine
 removal from the public ABI as part of PEP 393. I guess the reason
 nobody complained is because most 3.2 Linux builds used the UCS4 ABI
 instead, and the stable ABI hadn't seen broad adoption on Windows in
 the 3.2-3.3 time frame.

Not really. The intention was that the stable ABI wouldn't have any
UCS2/UCS4 denotation in the function names, see

http://hg.python.org/cpython/file/9186f4a18584/PC/python3.def

Functions that explicitly referred to Py_UNICODE were banned from
the ABI; functions that were mapped but shouldn't have been mapped
were meant to be unmapped.

However, it seems that this wasn't properly implemented, see

http://bugs.python.org/issue17432

 Regardless, this service already shows we've made some mistakes with
 the stable ABI in previous releases - it is indicating there are new
 symbols in the stable ABI for 3.3 and 3.4 that aren't properly guarded
 with version constraints. That means it is currently possible to set
 Py_LIMITED_API=0x0302 and get something that won't actually run
 properly on 3.2.

Depends on the operating system. On Windows, the import library has
much less additions; anything declared in the header files that
is not in python3.def is a bug in the header files (by default).

Regards,
Martin

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Gmane not functioning.

2014-04-02 Thread Terry Reedy
Just to let those who read the list as a list (or via mail.python.org, 
as I just did as a backup) know, news.gmane.org appears to have 
stoppedreceiving new messages from mailing listsat about 0:30 this 
morning (apr 2). (I am judging this from the last recorded post on the 
super-busy linux kernallist 
http://news.gmane.org/gmane.linux.kernel/cutoff=1676398). So there will 
be some unknown number of people not reading and posting who might 
otherwise. Ditto for other lists.



-- Terry Jan Reedy
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com