[issue18090] dict_contains first argument declared register, and shouldn't be

2013-08-13 Thread Larry Hastings

Larry Hastings added the comment:

Closed as this is a subset of #18722.

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

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-31 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Guido, do you still believe in using 'register' in C code in general or in 
particular, for function arguments. Many of the uses in dictobject.c go back to 
your rev1256 and rev5396. The one that caught Larry's eye for dict_contains 
appears to be from the latter.

(Many other appearances are credited to Antoine as solipsis, though these may 
be from merges or something, and he has already said he thinks they could go.)

--
nosy: +gvanrossum, terry.reedy

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Larry Hastings

Larry Hastings added the comment:

I poked around in a draft of the next ANSI C standard dated April 12 2011.  
They don't have much to say about the semantics of register.  The definition 
is found in 6.7.1.6:

A declaration of an identifier for an object with storage-class
specifier register suggests that access to the object be as fast
as possible.

In a footnote they say you can't take the address of something declared 
register.

In 6.7.6.3.2 they explicitly allow using register as part of the 
specification of a function parameter.  However, in 6.9.2 they say register 
cannot appear as part of an external declaration, including those for functions.

6.9.2 is where I stake my claim.  If register is irrelevant to calling 
convention, then why would the C standard preclude using it in an external 
declaration?  If it had no effect on the call they wouldn't care.

Therefore, declaring a parameter as register affects its calling convention.  
(Or, it would, if register actually did anything). Therefore casting a 
function from using register to not using register is a bug.  Therefore we 
shouldn't do it.

--

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Stefan Krah

Stefan Krah added the comment:

+1 for removing all occurrences of register.


Regarding the grammar, we have:

function-definition:
declaration-specifiers-opt declarator declaration-list-opt 
compound-statement


So I think that part of an external declaration refers to the outermost
declaration-specifiers, not to some inner declaration-specifiers that are
part of the parameter-type-list. Otherwise it would also be forbidden to
use register in the compound-statement. ;)

Thus, IMO this is legal:

   a) int f (register int x) {return x;}


But this is not allowed:

   b) register int f (int x) {return x;}


As Mark said, a) does not alter the calling convention. It's just a request
to keep x in a register in the function body once the parameter passing is
done.

--
nosy: +skrah

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

 If register is irrelevant to calling convention, then why would the C
 standard preclude using it in an external declaration?

Maybe here external is the opposite of static: register is OK in a single 
translation unit (where the calling convention does not really matter), but not 
allowed between multiple .c files (which register, anyway?)

+1 for removing it.

--
nosy: +amaury.forgeotdarc

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Larry Hastings

Larry Hastings added the comment:

Having re-read the spec a couple times, I am now thoroughly confused and don't 
know what to think.  Certainly I now believe I was previously misinterpreting 
aspects of the spec.

I still think removing register from the parameter lists of external 
functions is a good idea.  But smart people work on CPython, particularly on 
dictobject.c, so I find it easy to believe I'm missing something.  If having it 
there is actually a good idea I'd love to learn why!

--

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Ezio Melotti

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


--
nosy: +ezio.melotti

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-30 Thread Mark Dickinson

Mark Dickinson added the comment:

 +1 for removing all occurrences of register.

Seconded.

--

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-29 Thread Larry Hastings

Changes by Larry Hastings la...@hastings.org:


--
nosy: +Mark.Shannon, rhettinger

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I would recommend suppressing all register keywords from our C source files. 
It shouldn't make any difference these days.

--
nosy: +pitrou

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-29 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +serhiy.storchaka

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-29 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +mark.dickinson

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-29 Thread Mark Shannon

Mark Shannon added the comment:

The register qualifier on the parameter does not alter the calling convention, 
it determines the storage class of the parameter variable within the function.

Having said that I am all in favour in removing any and all register 
declarations.

--

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-29 Thread Larry Hastings

Larry Hastings added the comment:

 The register qualifier on the parameter does not alter the calling
 convention, it determines the storage class of the parameter variable
 within the function.

You assert that declaring a parameter as register instructs the compiler that 
callers should pass in the argument on the stack, but the function should then 
copy it to a register?  Can you cite a reference?

(I admit in advance I can't cite a reference for my assertion that it asks to 
pass the argument in a register.  And we all know the register keyword is 
more or less an unfunny joke to the compiler anyway.)

--

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



[issue18090] dict_contains first argument declared register, and shouldn't be

2013-05-28 Thread Larry Hastings

New submission from Larry Hastings:

I'm monkeying around with CPython trunk, and just noticed the following 
declaration in Objects/dictobject.c:

static PyObject *
dict_contains(register PyDictObject *mp, PyObject *key)

Although dict_contains is a static method, it's cast to PyCFunction and stored 
in the methoddef array for the dict class.  Therefore it must be callable when 
cast to a PyCFunction--indeed, that's the only way it is ever called.

Although the register keyword is at best a vague hope, surely it'd be bad 
news if our wish was granted?  The first argument to the PyCFunction typedef is 
*not* declared register.  So if the caller pushed the first argument on the 
stack, and dict_contains went looking for its first argument in a register... 
kablooey.

Surely we must remove the register keyword to this function, and similarly 
clean up all other functions ever cast to PyCFunction or 
PyCFunctionWithKeywords.

The register keyword isn't just a euphemism for I want this code to go 
faster -ly yours,

--
components: Interpreter Core
messages: 190263
nosy: larry
priority: low
severity: normal
stage: needs patch
status: open
title: dict_contains first argument declared register, and shouldn't be
type: behavior
versions: Python 3.4

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