[issue3081] Py_(X)SETREF macros

2010-04-08 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue3081] Py_(X)SETREF macros

2010-04-08 Thread Mark Dickinson

Mark Dickinson  added the comment:

I agree with Raymond about the Py_INCREF.  I could see more uses for this macro 
without the Py_INCREF, especially for things like in-place arithmetic 
operations.  The following pattern appears a lot in code like 
Objects/longobject.c:

Old code:

/* add one to x */
temp = PyNumber_Add(x, one);
Py_DECREF(x);
x = temp;
if (x == NULL)
return NULL;


With a non-INCREF version of Py_SETREF:

/* add one to x */
Py_SETREF(x, PyNumber_Add(x, one));
if (x == NULL)
return NULL;

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue3081] Py_(X)SETREF macros

2010-04-08 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Py_ASSIGN could be a better name, but given the enthusiasm generated by this 
proposal, I think we might just as well close the issue.

--

___
Python tracker 

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



[issue3081] Py_(X)SETREF macros

2010-04-08 Thread Jean-Paul Calderone

Jean-Paul Calderone  added the comment:

The name suggests a different behavior to me - I assumed it would set the 
reference count to a specific value.  Maybe this is the kind of thing Raymond 
had in mind when he said "The mnemonic doesn't work for me".

--
nosy: +exarkun

___
Python tracker 

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



[issue3081] Py_(X)SETREF macros

2008-09-02 Thread Jesús Cea Avión

Changes by Jesús Cea Avión <[EMAIL PROTECTED]>:


--
nosy: +jcea

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-08-06 Thread Paul Pogonyshev

Paul Pogonyshev <[EMAIL PROTECTED]> added the comment:

Just to note, I proposed similar macro on the mailing list under the
name Py_ASSIGN.

--
nosy: +_doublep

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-28 Thread Antoine Pitrou

Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

Le samedi 28 juin 2008 à 20:12 +, Raymond Hettinger a écrit :
> Raymond Hettinger <[EMAIL PROTECTED]> added the comment:
> 
> -1 on the new macros.  The mnemonic doesn't work for me and the example 
> code fragments are to my eyes less readable than before.  These add to 
> the learning curve for reading and writing C extensions and provide 
> nearly zero benefits.  

They might not be ideal, but I think they can be helpful to avoid
writing incorrect code out of laziness. There is already Py_CLEAR with
similar purposes.

> Assigning from an INCREF feels weird.  It is somewhat at odds with our 
> coding style where we tend to stick with dirt simple C, trying to put 
> operations on different lines rather than combining too many step in a 
> single line.

Ok.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-28 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

-1 on the new macros.  The mnemonic doesn't work for me and the example 
code fragments are to my eyes less readable than before.  These add to 
the learning curve for reading and writing C extensions and provide 
nearly zero benefits.  

Assigning from an INCREF feels weird.  It is somewhat at odds with our 
coding style where we tend to stick with dirt simple C, trying to put 
operations on different lines rather than combining too many step in a 
single line.

--
nosy: +rhettinger

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-28 Thread Antoine Pitrou

Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

This new patch avoids using temporary variables named "new", it also
adopts the "do { ... } while (0)" idiom for definition of the macros.

Added file: http://bugs.python.org/file10761/py_setref.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-13 Thread Alexander Belopolsky

Alexander Belopolsky <[EMAIL PROTECTED]> added the comment:

A comment on the patch:

Since object.h may be included from C++ extensions, you should not use a 
C++ keyword "new" as a variable name.

--
nosy: +belopolsky

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-11 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

Sorry for the confusion. It seems to me this sort of thing would be
useful in 2.6, too, so I marked it.

--
versions: +Python 3.0

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-11 Thread Antoine Pitrou

Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

Benjamin, the patch is against py3k, also it might also apply cleanly on
trunk...

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-11 Thread Benjamin Peterson

Changes by Benjamin Peterson <[EMAIL PROTECTED]>:


--
nosy: +benjamin.peterson
type:  -> feature request
versions: +Python 2.6 -Python 3.0

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-11 Thread Antoine Pitrou

Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

FWIW, I also wanted to propose for Py_INCREF(op) to evaluate as (op), so
that it can be used as return or assignment value, e.g.:
return Py_INCREF(result);
or:
self->var = Py_INCREF(obj);

but it's perhaps a bit more controversial.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3081] Py_(X)SETREF macros

2008-06-11 Thread Antoine Pitrou

New submission from Antoine Pitrou <[EMAIL PROTECTED]>:

This is an implementation of the Py_SETREF and Py_XSETREF macros
proposed in http://mail.python.org/pipermail/python-dev/2008-May/079862.html

As an example, I added a few conversions among the extension modules.

--
components: Extension Modules, Interpreter Core
files: py_setref.patch
keywords: patch
messages: 68009
nosy: pitrou
severity: normal
status: open
title: Py_(X)SETREF macros
versions: Python 3.0
Added file: http://bugs.python.org/file10591/py_setref.patch

___
Python tracker <[EMAIL PROTECTED]>

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