Re: bigint - python long

2012-09-11 Thread Ellery Newcomer
On 09/10/2012 10:50 PM, Russel Winder wrote: Python 2 and Python 3 are totally different in this regard. I don't have a obvious proposal to make to avoid having PyD for Python 2 and a different PyD for Python 3, but the six package might have some hints as it is intended to support creating

Re: bigint - python long

2012-09-11 Thread Ellery Newcomer
On 09/05/2012 07:10 PM, bearophile wrote: Ellery Newcomer: Yep. Oh, good. Have any suggestions for supported conversion out of the box? There are several important cases, like: Some D lazy ranges == Python lazy iterators/generators array.array == D arrays NumPy arrays == D arrays

Re: D and SCons [ was Re: bigint - python long ]

2012-09-10 Thread Johannes Pfau
Am Sun, 09 Sep 2012 12:55:19 -0700 schrieb Brad Roberts bra...@puremagic.com: On 9/9/2012 1:15 AM, Johannes Pfau wrote: Am Sat, 08 Sep 2012 16:25:49 +0100 schrieb Russel Winder rus...@winder.org.uk: On Sat, 2012-09-08 at 07:20 -0700, Ellery Newcomer wrote: […] Okay, here:

Re: D and SCons [ was Re: bigint - python long ]

2012-09-10 Thread Johannes Pfau
Am Mon, 10 Sep 2012 14:48:30 +0200 schrieb Johannes Pfau nos...@example.com: Sorry, I should have said 'It'll _probably_ never be supported in gdc'. There are some possible solutions but: * It must be good enough to get approved when gdc is merged into gcc. (remember it must be portable

Re: bigint - python long

2012-09-10 Thread Ellery Newcomer
On 09/05/2012 07:10 PM, bearophile wrote: NumPy arrays == D arrays I've been thinking about this one a bit more, and I am not sure it belongs in pyd. First, the conversion is not symmetric. One can convert a numpy.ndarray to a d array like so: PyObject* ndarray; double[][] matrix =

Re: bigint - python long

2012-09-10 Thread bearophile
Ellery Newcomer: I've been thinking about this one a bit more, and I am not sure it belongs in pyd. I understand. The point of Pyd is to interface D and Python, while NumPy is something external. So if you find difficulties just keep it out. Adding it later is possible. Bye, bearophile

Re: bigint - python long

2012-09-10 Thread Ellery Newcomer
On 09/10/2012 12:11 PM, bearophile wrote: I understand. The point of Pyd is to interface D and Python, while NumPy is something external. So if you find difficulties just keep it out. Adding it later is possible. Thing is, pyd will convert a ndarray to d array already, it just won't do it

Re: bigint - python long

2012-09-10 Thread Russel Winder
On Mon, 2012-09-10 at 15:54 -0700, Ellery Newcomer wrote: […] OT Bugger, I'm going to have to go through pyd and replace all usages of str with unicode. /OT Python 2 and Python 3 are totally different in this regard. I don't have a obvious proposal to make to avoid having PyD for Python 2 and

Re: D and SCons [ was Re: bigint - python long ]

2012-09-09 Thread Johannes Pfau
Am Sat, 08 Sep 2012 16:25:49 +0100 schrieb Russel Winder rus...@winder.org.uk: On Sat, 2012-09-08 at 07:20 -0700, Ellery Newcomer wrote: […] Okay, here: https://bitbucket.org/ariovistus/deimos-elfutils/overview I have some code with a working makefile and a nonworking SConstruct

Re: D and SCons [ was Re: bigint - python long ]

2012-09-09 Thread Russel Winder
On Sun, 2012-09-09 at 10:15 +0200, Johannes Pfau wrote: […] Please note that pragma(lib) is an evil feature. For example it will never work in gdc. So this is a DMD-only (*) feature and not a feature of the D programming language per se? (*) and hence LDC. -- Russel.

Re: D and SCons [ was Re: bigint - python long ]

2012-09-09 Thread Brad Roberts
On 9/9/2012 1:15 AM, Johannes Pfau wrote: Am Sat, 08 Sep 2012 16:25:49 +0100 schrieb Russel Winder rus...@winder.org.uk: On Sat, 2012-09-08 at 07:20 -0700, Ellery Newcomer wrote: […] Okay, here: https://bitbucket.org/ariovistus/deimos-elfutils/overview I have some code with a working

Re: bigint - python long

2012-09-08 Thread Russel Winder
On Sat, 2012-09-08 at 00:58 +0200, bearophile wrote: […] If you support NumPy well and efficiently through Pyd, I think some people will start using the D language just for this :-) NumPy is good but it usually forces you to program vectorially, like Matlab. Sometimes this is not nice, so

Re: bigint - python long

2012-09-08 Thread Russel Winder
On Fri, 2012-09-07 at 15:21 -0700, Ellery Newcomer wrote: On 09/06/2012 12:07 AM, Russel Winder wrote: […] just used your scons fork to build the pyd embedded unittests. works pretty nice Splendid :-) If you see any problems or glitches, let me know and/or post a bug report. Although I said

Re: bigint - python long

2012-09-08 Thread Ellery Newcomer
On 09/08/2012 03:09 AM, Russel Winder wrote: On Fri, 2012-09-07 at 15:21 -0700, Ellery Newcomer wrote: On 09/06/2012 12:07 AM, Russel Winder wrote: […] just used your scons fork to build the pyd embedded unittests. works pretty nice Splendid :-) Okay, here:

Re: D and SCons [ was Re: bigint - python long ]

2012-09-08 Thread Russel Winder
On Sat, 2012-09-08 at 07:20 -0700, Ellery Newcomer wrote: […] Okay, here: https://bitbucket.org/ariovistus/deimos-elfutils/overview I have some code with a working makefile and a nonworking SConstruct file. I believe the issue is the header files have pragma(lib, X) in them, and a single

Re: bigint - python long

2012-09-07 Thread Ellery Newcomer
On 09/06/2012 09:48 AM, Ellery Newcomer wrote: On 09/05/2012 11:19 PM, Jacob Carlborg wr Associative arrays? check. eh, that was check as in yes, not check as in look it up yourself. didn't seem ambiguous at the time.

Re: bigint - python long

2012-09-07 Thread Ellery Newcomer
On 09/06/2012 12:07 AM, Russel Winder wrote: I am guessing this is interfacing to CPython, remember there is also PyPy and ActiveState, they have different ways of doing things. Well the ActiveState C API will be very close to the CPython C API, but PyPy (which is the best Python 2.7 just now)

Re: bigint - python long

2012-09-07 Thread bearophile
Ellery Newcomer: I had a look at numpy, and at least ndarray supports the new style buffer interface (which is pretty freaking complicated), so convertion is totally doable. I'll fold in support as soon as I can get dmd to stop stabbing me in the face. If you support NumPy well and

Re: bigint - python long

2012-09-06 Thread Jacob Carlborg
On 2012-09-06 04:10, bearophile wrote: There are several important cases, like: Some D lazy ranges == Python lazy iterators/generators array.array == D arrays NumPy arrays == D arrays Associative arrays? -- /Jacob Carlborg

Re: bigint - python long

2012-09-06 Thread Russel Winder
Sorry, I missed earlier bits of this thread… On Wed, 2012-09-05 at 19:37 -0700, Ellery Newcomer wrote: On 09/05/2012 07:10 PM, bearophile wrote: Some D lazy ranges == Python lazy iterators/generators I'll look into this one. array.array == D arrays just checked, looks like we

Re: bigint - python long

2012-09-06 Thread Don Clugston
On 05/09/12 21:23, Paul D. Anderson wrote: On Wednesday, 5 September 2012 at 18:13:40 UTC, Ellery Newcomer wrote: Hey. Investigating the possibility of providing this conversion in pyd. Python provides an api for accessing the underlying bytes. std.bigint seemingly doesn't. Am I missing

Re: bigint - python long

2012-09-06 Thread bearophile
Ellery Newcomer: array.array == D arrays just checked, looks like we have it: PyStmts(q{from array import array; a = array('i', [44,33,22,11]);}, testing); assert(PyEval!(int[])(a, testing) == [44,33,22,11]); I think if the python object is iterable, it can be converted to array.

Re: bigint - python long

2012-09-06 Thread Ellery Newcomer
On 09/05/2012 11:19 PM, Jacob Carlborg wrote: On 2012-09-06 04:10, bearophile wrote: There are several important cases, like: Some D lazy ranges == Python lazy iterators/generators array.array == D arrays NumPy arrays == D arrays Associative arrays? check.

Re: bigint - python long

2012-09-06 Thread Ellery Newcomer
On 09/06/2012 04:11 AM, bearophile wrote: Ellery Newcomer: array.array == D arrays just checked, looks like we have it: PyStmts(q{from array import array; a = array('i', [44,33,22,11]);}, testing); assert(PyEval!(int[])(a, testing) == [44,33,22,11]); I think if the python object is

bigint - python long

2012-09-05 Thread Ellery Newcomer
Hey. Investigating the possibility of providing this conversion in pyd. Python provides an api for accessing the underlying bytes. std.bigint seemingly doesn't. Am I missing anything?

Re: bigint - python long

2012-09-05 Thread Paul D. Anderson
On Wednesday, 5 September 2012 at 18:13:40 UTC, Ellery Newcomer wrote: Hey. Investigating the possibility of providing this conversion in pyd. Python provides an api for accessing the underlying bytes. std.bigint seemingly doesn't. Am I missing anything? No, I don't believe so. AFAIK

Re: bigint - python long

2012-09-05 Thread Paul D. Anderson
On Wednesday, 5 September 2012 at 19:23:11 UTC, Paul D. Anderson wrote: No, I don't believe so. AFAIK there is no public access to the underlying array, but I think it is a good idea. I meant to say I think that access to the array is a good idea, not the lack of access. Words are hard!

Re: bigint - python long

2012-09-05 Thread bearophile
Ellery Newcomer: Investigating the possibility of providing this conversion in pyd. Are you updating Pyd? :-) Bye, bearophile

Re: bigint - python long

2012-09-05 Thread Ellery Newcomer
On 09/05/2012 05:02 PM, bearophile wrote: Ellery Newcomer: Investigating the possibility of providing this conversion in pyd. Are you updating Pyd? :-) Bye, bearophile Yep. Have any suggestions for supported conversion out of the box? From the standard library, I already have Complex,

Re: bigint - python long

2012-09-05 Thread bearophile
Ellery Newcomer: Yep. Oh, good. Have any suggestions for supported conversion out of the box? There are several important cases, like: Some D lazy ranges == Python lazy iterators/generators array.array == D arrays NumPy arrays == D arrays Also, which of the following looks more

Re: bigint - python long

2012-09-05 Thread Ellery Newcomer
On 09/05/2012 07:10 PM, bearophile wrote: Some D lazy ranges == Python lazy iterators/generators I'll look into this one. array.array == D arrays just checked, looks like we have it: PyStmts(q{from array import array; a = array('i', [44,33,22,11]);}, testing); assert(PyEval!(int[])(a,