[issue1172711] long long support for array module

2011-09-21 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 New changeset 672b63aff0f4 by Meador Inge in branch 'default'

Woops, I wrote the wrong module name. Thanks for fixing it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 15659e0e2b2e by Meador Inge in branch 'default':
Issue #1172711: Add 'long long' support to the array module.
http://hg.python.org/cpython/rev/15659e0e2b2e

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-20 Thread Meador Inge

Changes by Meador Inge mead...@gmail.com:


--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 3c56e546dc60 by Victor Stinner in branch 'default':
Issue #1172711: Update What's New in Python 3.3 document for the struct module
http://hg.python.org/cpython/rev/3c56e546dc60

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 672b63aff0f4 by Meador Inge in branch 'default':
Issue #1172711: Update What's New in Python 3.3 document for the array module.
http://hg.python.org/cpython/rev/672b63aff0f4

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-16 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

 I am OK with applying the fix for this issue first.

I also think this should be committed first.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-16 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Agreed.  Commit first;  worry about __int__ and __index__ later.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-14 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

@meadori: please write the version of your patch directly in the filename. For 
example, I use the pattern: name.patch, name-2.patch, name-3.patch, ...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-13 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
versions: +Python 3.3 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-13 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Yes, please let's not add any new __int__-based duck typing here; IMO, we 
should be moving away from such uses of __int__.  I'd be fine with __index__ 
based duck-typing.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-13 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

 Yes, please let's not add any new __int__-based duck typing here;

Mark, just to clarify a bit, the behavior is already there in the array module 
(by way of 'PyLong_AsLong').  The fact that it is there was picked up on a code 
review for this issue.

Anyway, I think we should open a new issue to track the '__index__' vs. 
'__int__' stuff.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-13 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 Mark, just to clarify a bit, the behavior is already there in the array module

Okay, understood.  But the new 'long long' support provided by this patch still 
allows for __int__-based duck typing, right?

 array('Q', [1, 2, Decimal(3.2)])
array('Q', [1, 2, 3])

That's the new duck typing I meant.  I see this acceptance of things with an 
__int__ method as a mistake, and my gut reaction earlier was that it seems 
wrong to propagate that mistake into the new long long functionality, even 
though it's already present in other places in the array module.

On second thoughts though, it would be a peculiar inconsistency to be able to 
pass Decimal objects to array('L', ...) but not to array('Q', ...).  So 
probably better to accept this behaviour for now, and open another issue for 
the __int__ / __index__ discussion, as you suggest.

BTW, the patch and tests look good to me, and all tests pass here (OS X !0.6, 
64-bit) (Well, not quite true, but I fail to see how these changes could be 
responsible for the test_socket and test_packaging failures I'm seeing :-).  I 
get compile-time warnings from the 'int' declarations that should be 
'Py_ssize_t', but I understand that's taken care of already...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-13 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

 Okay, understood.  But the new 'long long' support provided by this patch 
 still allows for __int__-based duck typing, right?

Yes, but ...

 That's the new duck typing I meant.  I see this acceptance of things with an 
 __int__ method as a mistake, and my gut
 reaction earlier was that it seems wrong to propagate that mistake into the 
 new long long functionality, even though it's already
 present in other places in the array module.

 On second thoughts though, it would be a peculiar inconsistency to be able to 
 pass Decimal objects to array('L', ...) but not
 to array('Q', ...).  So probably better to accept this behaviour for now, and 
 open another issue for the __int__ / __index__ discussion,
 as you suggest.

... I had this inconsistency in mind.  I opened issue12974 for the
__int__/__index__ problem.

Now we just have to figure out which issue gets fixed first :-D  I am
OK with applying the fix for this issue first.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-13 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

Updated patch with the 'Py_ssize_t' fixes.

--
Added file: http://bugs.python.org/file23148/issue-1172711.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-12 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

I made the observation on Rietveld that the following code is never
executed by the test suite. The same applies to similar existing
passages in arraymodule.c:

http://bugs.python.org/review/1172711/diff/3310/10310#newcode394


Meador correctly pointed out that the code allows for duck typing.
But the struct module (and by extension memoryview that must follow
the struct module) don't:

 import array, struct
 a = array.array('L', [1,2,3])
 class T(object):
... def __init__(self, value):
... self.value = value
... def __int__(self):
...  return self.value
...
 a = array.array('L', [1,2,3])
 struct.pack_into('L', a, 0, 9)
 a
array('L', [9, 2, 3])
 a[0] = T(100)
 a
array('L', [100, 2, 3])
 struct.pack_into('L', a, 0, T(200))
Traceback (most recent call last):
  File stdin, line 1, in module
struct.error: required argument is not an integer


I vastly prefer the struct module behavior. Since the code isn't executed
by any tests:

Is it really the intention for array to allow duck typing? The documentation
says:

This module defines an object type which can compactly represent an array
 of basic values: characters, integers, floating point numbers.

Basic value doesn't sound to me like anything that has an __int__() method.


Also, consider this:

 sum([T(1),T(2),T(3)])
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unsupported operand type(s) for +: 'int' and 'T'

 sum(array.array('L', [T(1),T(2),T(3)]))
6

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-12 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

 import array, struct
 a = array.array('L', [1,2,3])
 class T(object):
 ...     def __init__(self, value):
 ...         self.value = value
 ...     def __int__(self):
 ...          return self.value
 ...
 a = array.array('L', [1,2,3])
 struct.pack_into('L', a, 0, 9)
 a
 array('L', [9, 2, 3])
 a[0] = T(100)
 a
 array('L', [100, 2, 3])
 struct.pack_into('L', a, 0, T(200))
 Traceback (most recent call last):
  File stdin, line 1, in module
 struct.error: required argument is not an integer


 I vastly prefer the struct module behavior. Since the code isn't executed
 by any tests:

Yeah, but if it is a good feature we can always add more tests.  I think the
real issue is whether or not this behavior is even desirable.  Also, similar
behavior can be achieved with struct by using '__index__':

...  def __init__(self, value):
...  self.value = value
...  def __int__(self):
...   return self.value
...  def __index__(self):
...   return self.value
...
 a = array.array('L', [1,2,3])
 struct.pack_into('L', a, 0, T(200))
 a
array('L', [200, 2, 3])

Also, check out issue1530559.  Originally, struct did allow the
'__int__' and '__long__' behavior, but it was deprecated and replaced
with '__index__'.  Maybe we should do the same for array?

IMO, having some way to convert objects to integers is a nice feature
and I think we will find more cases like the PyCUDA case from
issue1530559 where folks need this.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-11 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

I left some remarks on Rietveld.

--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

+if have_long_long:
+class LongLongTest(SignedNumberTest):
+...

It is maybe better to use @unittest.skipIf(not have_long_long, 'need long long 
support'). Except of this nit, the patch looks correct.

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-08 Thread Meador Inge

Changes by Meador Inge mead...@gmail.com:


Added file: http://bugs.python.org/file23121/issue-1172711.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-08 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

Victor, I like the decorator approach much better.  Thanks.  Attached is a new 
patch with that update.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-05 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


--
nosy:  -arigo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-09-04 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

Here is a refresh of this patch for 3.3.  Please review.

--
Added file: http://bugs.python.org/file23100/issue-1172711.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2011-01-12 Thread Matt Chaput

Matt Chaput m...@sidefx.com added the comment:

This is an important feature to me. Now I get to redo a bunch of code to have 
two completely different code paths to do the same thing because nobody could 
be bothered to keep array up-to-date.

--
nosy: +mattchaput

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2010-08-24 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

Overall the patch looks good.  I don't think it is an extremely important 
feature, but similar support is already available in other places (e.g. 
'struct', 'ctypes').

Here is a patch updated for py3k with some minor additions:

   (1) Fixed some doc inconsistencies.
   (2) Added pickling support for the new type codes.  The special
   pickling support looks only to be in py3k.

(2) needs unit tests if possible.  If anyone has any good ideas on how to test, 
then I would be happy to implement the tests.

--
stage: unit test needed - patch review
Added file: http://bugs.python.org/file18627/issue-1172711.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2010-08-03 Thread Meador Inge

Changes by Meador Inge mead...@gmail.com:


--
nosy: +minge

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2010-06-24 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Seems like a reasonable addition to me.  Anyone feel like refreshing the patch 
so that it applies to py3k?

--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2010-06-24 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

BTW, the PyLong_AsUnsignedLongLong BadInternalCall has long since disappeared.  
I agree with Armin Rigo that the conversion functions in longobject.c are a 
mess, though (and also that cleanup is difficult).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2010-06-24 Thread Senthil Kumaran

Changes by Senthil Kumaran orsent...@gmail.com:


--
versions: +Python 3.2 -Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2010-06-23 Thread Craig McQueen

Craig McQueen pyt...@craig.mcqueen.id.au added the comment:

So it looks as though this isn't going in to Python 2.7.

How about 3.x?

--
nosy: +cmcqueen1975

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2009-07-03 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

How about this patch? I haven't tested so intensely, but testcase seems
working.

--
nosy: +ocean-city
Added file: http://bugs.python.org/file14438/array_long_long.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2009-07-03 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:


Added file: http://bugs.python.org/file14439/array_long_long.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2009-07-03 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:


Removed file: http://bugs.python.org/file14438/array_long_long.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1172711] long long support for array module

2009-02-15 Thread Daniel Diniz

Changes by Daniel Diniz aja...@gmail.com:


--
components: +Extension Modules -Library (Lib)
stage:  - test needed
type:  - feature request
versions: +Python 2.7 -Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1172711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com