[issue887237] Machine integers

2013-10-13 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
versions: +Python 3.4 -Python 3.2

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



[issue887237] Machine integers

2012-12-05 Thread Bruno Dupuis

Changes by Bruno Dupuis bdup...@lisael.org:


--
nosy: +bruno.dupuis

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



[issue887237] Machine integers

2011-03-27 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
nosy: +durban

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



[issue887237] Machine integers

2011-03-26 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

You could write a Python script to generator the methods.

--
nosy: +benjamin.peterson

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



[issue887237] Machine integers

2010-12-01 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

As far as I understand, the main concern about issue887237.diff was code 
duplication.  There are two ways to fight it: C preprocessor tricks as in 
issue887237-macro.diff and code generation as done in numpy.  With improved 
macro support in many compilers and debuggers, preprocessor approach may be 
preferable.  However I cannot move this issue forward until those who objected 
to code duplication review the latest patch.  Unassigning.

--
assignee: belopolsky - 
nosy:  -BreamoreBoy

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



[issue887237] Machine integers

2010-07-14 Thread Mark Lawrence

Mark Lawrence breamore...@yahoo.co.uk added the comment:

Perhaps people could review the latest patch in view of the following.

1) Quote from Mark Dickinson msg75815

I think this would be valuable for rapid prototyping
of an algorithm in Python before translating it into
C.  In particular, it might help with detecting some
common C code bugs involving undefined behaviour---for
example, overflow in signed-integer arithmetic.

2) issue1621 Do not assume signed integer overflow behavior

Perhaps this could be treated as purely experimental?  (This might have been 
suggested already, sorry if I've missed it). Whatever happens I'd be glad to 
help out if possible, the big asset I have compared to others is time as I only 
work part time.

--
nosy: +BreamoreBoy

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



[issue887237] Machine integers

2010-06-08 Thread Alexander Belopolsky

Changes by Alexander Belopolsky belopol...@users.sourceforge.net:


--
assignee:  - belopolsky
components: +Extension Modules, ctypes -Library (Lib)
nosy:  -Alexander.Belopolsky
stage:  - patch review
versions: +Python 3.2

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



[issue887237] Machine integers

2010-03-05 Thread Thomas Heller

Thomas Heller thel...@ctypes.org added the comment:

 Code duplication is unavoidable because the goal is to give access to
 machine arithmetics which means (# types) x (# operations) of very
 similar looking functions. I considered reducing (perceived) code
 duplication through some pre-processor magic, but doing so would make
 code much harder to understand and almost impossible to debug.
 
 Carefully written macros shouldn't be hard to understand.
 At least there wouldn't be the risk of overlooking one of the methods
 when making modifications.

The code duplication in Alex's patch is indeed enormous.  I can see
two solutions to avoid (or work around) them.  Use of macros, or writing
a Python script that generates the C-code.  Anyway, I guess his patch
is some example code, not more.  (Using C++ overloaded functions or even
templates would be another - but only theoretical - possibility).

 I would like to hear from Thomas before introducing macros in this
 code.  I tried to follow the style of cfield.c which shows similar
 code duplication.
 
 There are also some questions that need to be answered before
 polishing the code.
 
 1. Should mixed arithmetics be supported?
 2. Should we do anything special about floating point operations?
 Wrapping them in PyFPE_START/STOP_PROTECT?
 3. Should we support in-place operations?
 4. Bitwise operations on integers?

I would answer 1, 3, and 4, with 'yes'. However, this grows the code size
by another dimension since we now have #types * #operation * #types.

My answer for question 3 is 'I don't know'.

Before I forget:  It may be possible to implement ctypes number methods
as a third-party module by implementing a mixin class, and replacing the
c_... type definitions in Lib/ctypes/__init__.py.

--

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



[issue887237] Machine integers

2010-03-05 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

Attaching a patch that is equivalent toissue887237.diff, but uses preprocessor 
to generate repetitive code.

--
Added file: http://bugs.python.org/file16466/issue887237-macro.diff

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



[issue887237] Machine integers

2010-03-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Le Fri, 05 Mar 2010 02:21:30 +,
Alexander Belopolsky rep...@bugs.python.org a écrit :
 
 Code duplication is unavoidable because the goal is to give access to
 machine arithmetics which means (# types) x (# operations) of very
 similar looking functions. I considered reducing (perceived) code
 duplication through some pre-processor magic, but doing so would make
 code much harder to understand and almost impossible to debug.

Carefully written macros shouldn't be hard to understand.
At least there wouldn't be the risk of overlooking one of the methods
when making modifications.

--

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



[issue887237] Machine integers

2010-03-04 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

I would like to hear from Thomas before introducing macros in this
code.  I tried to follow the style of cfield.c which shows similar
code duplication.

There are also some questions that need to be answered before
polishing the code.

1. Should mixed arithmetics be supported?
2. Should we do anything special about floating point operations?
Wrapping them in PyFPE_START/STOP_PROTECT?
3. Should we support in-place operations?
4. Bitwise operations on integers?

On Thu, Mar 4, 2010 at 9:29 PM, Raymond Hettinger
rep...@bugs.python.org wrote:

 Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

 Look at Modules/operator.c for example of an effective use of macros to 
 minimize code duplication.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue887237
 ___


--

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



[issue887237] Machine integers

2008-12-10 Thread Alexander Belopolsky

Changes by Alexander Belopolsky [EMAIL PROTECTED]:


Added file: http://bugs.python.org/file12323/ctypes-numbermixins-1.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue887237
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue887237] Machine integers

2008-12-10 Thread Thomas Heller

Thomas Heller [EMAIL PROTECTED] added the comment:

 One difficulty with the patch is that the original ctypes code
 contained a tp_as_number ...

This can be solved by changing the order of bases for c_type classes.  
See attached.

Cool! Why didn't I think of that myself?

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue887237
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue887237] Machine integers

2008-11-15 Thread Thomas Heller

Thomas Heller [EMAIL PROTECTED] added the comment:

I wonder if a patch for ctypes like this (which is not yet complete)
could be used to implement this, or MUST it be implemented in C?

The patch contains a mixin class that implements the numeric methods. 
However, the actual operation takes place in Python; only the operands
are converted into ctypes types first, the operand is applied to the
value, and the result is converted to a ctypes instance again.

One difficulty with the patch is that the original ctypes code contained
a tp_as_number member where only the nb_nonzero slot was actually
implemented; this prevented the mixin class to do it's work (Python
didn't call the special methods.  I wonder if there is a bug somewhere...).

--
keywords: +patch
Added file: http://bugs.python.org/file12016/ctypes-numbermixins.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue887237
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue887237] Machine integers

2008-11-13 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

Is it be feasible to add arithmetic operations
to the ctypes integer types?  Since ctypes is now
in the core, it would seem better to enhance ctypes
than provide a new module.

I think this would be valuable for rapid prototyping
of an algorithm in Python before translating it into
C.  In particular, it might help with detecting some
common C code bugs involving undefined behaviour---for
example, overflow in signed-integer arithmetic.

--
nosy: +marketdickinson

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue887237
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com