Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-07 Thread Skip Montanaro
Not a big deal. I did it this way: // PyPy introduced the PyDateTime_DELTA_* API as functions even though // they aren't available in CPython until v3.x. To make matters // slightly worse, in CPython 3.x they are defined as macros. #if !defined(PYPY_VERSION) && PY_MAJOR_VERSION < 3 #define PyDat

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-07 Thread Amaury Forgeot d'Arc
2013/9/7 Armin Rigo > It seems that "struct PyDateTime_Delta" is supposed to be purely > read-only. In case situation, wouldn't it make sense to expose a > structure with a similar layout? I don't think we care about the > overhead of copying three words; the only annoying case is about > read-

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-07 Thread Amaury Forgeot d'Arc
2013/9/7 Skip Montanaro > On Fri, Sep 6, 2013 at 6:13 PM, Skip Montanaro wrote: > >> Not sure I understand. Or did you mean "why are those declarations not > in > >> datetime.h"? > > > > Yes, sorry about the typo. > > Alas, I am still confused. The PyDateTime_DELTA_GET_* macros aren't > defined

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-07 Thread Armin Rigo
Hi Skip, hi Amaury, On Sat, Sep 7, 2013 at 3:16 AM, Skip Montanaro wrote: > Alas, I am still confused. The PyDateTime_DELTA_GET_* macros aren't > defined for CPython until the 3.x series. (There are macros in 2.7, > but they are defined in datetimemodule.c, not in a public header file. > PyPy dec

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-06 Thread Skip Montanaro
On Fri, Sep 6, 2013 at 6:13 PM, Skip Montanaro wrote: >> Not sure I understand. Or did you mean "why are those declarations not in >> datetime.h"? > > Yes, sorry about the typo. Alas, I am still confused. The PyDateTime_DELTA_GET_* macros aren't defined for CPython until the 3.x series. (There ar

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-06 Thread Skip Montanaro
> Not sure I understand. Or did you mean "why are those declarations not in > datetime.h"? Yes, sorry about the typo. > Then the answer is: because all these functions are generated during PyPy > translation. > The corresponding declarations are written in pypy_decl.h Makes sense... Skip __

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-06 Thread Skip Montanaro
> Sure. Use macros like PyDateTime_DELTA_GET_DAYS(). The structure is not part > of the public API anyway. > With CPython the macros don't make any difference, but PyPy implements them > as actual function calls. Ah, that makes sense. The code in question was written when we were still using Pyth

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-06 Thread Amaury Forgeot d'Arc
2013/9/7 Skip Montanaro > > Sure. Use macros like PyDateTime_DELTA_GET_DAYS(). The structure is not > part > > of the public API anyway. > > With CPython the macros don't make any difference, but PyPy implements > them > > as actual function calls. > > Ah, that makes sense. The code in question

Re: [pypy-dev] PyPy's PyDateTime_Delta definition

2013-09-06 Thread Amaury Forgeot d'Arc
2013/9/6 Skip Montanaro > Python 2.7's PyDateTime_Delta structure is defined like this: > > typedef struct > { > PyObject_HEAD > long hashcode; /* -1 when unknown */ > int days; /* -MAX_DELTA_DAYS <= days <= > MAX_DELTA_DAYS */ > int seconds;