[Python-Dev] Why does STORE_MAP not take a parameter?

2015-01-21 Thread Neil Girdhar
Building argument lists and dicts in python entails the following opcode
pattern:

  1   0 BUILD_MAP3
  3 LOAD_CONST   0 (2)
  6 LOAD_CONST   1 (1)
  9 STORE_MAP
 10 LOAD_CONST   2 (4)
 13 LOAD_CONST   3 (3)
 16 STORE_MAP
 17 LOAD_CONST   4 (6)
 20 LOAD_CONST   5 (5)
 23 STORE_MAP

Building lists on the other hand works like this:

  1   0 LOAD_CONST   0 (1)
  3 LOAD_CONST   1 (2)
  6 LOAD_CONST   2 (3)
  9 BUILD_LIST   3


Why not have BUILD_MAP work like BUILD_LIST?   I.e., STORE_MAP takes a
parameter n and adds the last n pairs of stack elements into the n-1 stack
element (the dictionary).

This means that the data would live on the stack until it is all suddenly
transferred to the dict, but I'm not sure about the effect on performance
(whether positive or negative).

It does save on instruction cache misses.

It should be an easy change to implement since all calls to BUILD_MAP could
be replaced with "BUILD_MAP 1" and then optimized later.

Best,

Neil
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] incorrect docstring for sys.int_info.sizeof_digit?

2015-01-21 Thread Pfeiffer, Phillip E., IV
Apologies if this has already been reported; I couldn't find a readily 
searchable archive for this mailing list (and apologies if I've just missed it).

Issue: the docstring for sys.int_info_.sizeof_digit appears to be amiss; see 
below.

--
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:16:31) [MSC v.1600 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from sys import int_info
>>> print(sys.int_info.sizeof_digit.__doc__)
int(x=0) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is a number, return x.__int__().  For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base.  The literal can be preceded by '+' or '-' and be surrounded
by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4
>>>


-- Phil

===
 Phil Pfeiffer/ East TN State U.|  Kindness in thought leads to 
wisdom.
 Dept. of Computing / P.O. Box 70711   |  Kindness in speech leads to eloquence.
 Johnson City, TN.  37614-1266  |  Kindness in action leads to love.
phil (at) etsu.edu  (423) 439-5355   |-- 
Lao-Tsu
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] sorry for the last e-mail

2015-01-21 Thread Pfeiffer, Phillip E., IV
Apologies for being stupid.  I've been away from Python for awhile, and just 
realized that I'm simply seeing the docstring for int when I check out 
sys.int_info.whatever, where .whatever is an int-valued attribute.

While it would be nice to have a clearer description of the sys.int_info's 
attributes in the sys.int_info docstring, that's a different kettle of fish.

Again, apologies.

-- Phil

===
 Phil Pfeiffer/ East TN State U.|  Kindness in thought leads to 
wisdom.
 Dept. of Computing / P.O. Box 70711   |  Kindness in speech leads to eloquence.
 Johnson City, TN.  37614-1266  |  Kindness in action leads to love.
phil (at) etsu.edu  (423) 439-5355   |-- 
Lao-Tsu
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] incorrect docstring for sys.int_info.sizeof_digit?

2015-01-21 Thread Tim Golden
On 21/01/2015 11:07, Pfeiffer, Phillip E., IV wrote:
> Apologies if this has already been reported; I couldn't find a
> readily searchable archive for this mailing list (and apologies if
> I've just missed it).

Depending on "readily searchable", this isn't too bad:

http://markmail.org/search/?q=list%3Aorg.python.python-dev+integer+docstring

TJG
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] incorrect docstring for sys.int_info.sizeof_digit?

2015-01-21 Thread R. David Murray
On Wed, 21 Jan 2015 14:53:19 +, Tim Golden  wrote:
> On 21/01/2015 11:07, Pfeiffer, Phillip E., IV wrote:
> > Apologies if this has already been reported; I couldn't find a
> > readily searchable archive for this mailing list (and apologies if
> > I've just missed it).
> 
> Depending on "readily searchable", this isn't too bad:
> 
> http://markmail.org/search/?q=list%3Aorg.python.python-dev+integer+docstring

But, if you are searching to see if a bug has been reported, you want to
search the tracker at bugs.python.org, not the python-dev mailing list.

--David
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Undefined dlopen When Building Module On Android

2015-01-21 Thread Cyd Haselton
On Mon, Jan 19, 2015 at 5:23 PM, Cyd Haselton  wrote:
> On Mon, Jan 19, 2015 at 8:51 AM, Cyd Haselton  wrote:
>> Hello,
>> I'm struggling with a build issue on Android; I've posted to the
>> general python list with no result, so I'm re-posting here in hopes
>> that someone can help.  If this is the wrong place feel free to let me
>> know.
>>
>> I'm attempting to build Python 2.7.8 on my Android device; I'm using
>> an environment that simulates a Linux filesystem within the Android
>> terminal using a port of fakechroot.  Within that environment I've
>> ported and/or bootstrapped a number of Linux utilities (curl, git,
>> openssl, gcc)
>>
>> I run ./configure, then make, and the executable and library are
>> built.  The problem occurs when build_ext is run; the newly built
>> python executable builds, then links _struct, and immediately
>> afterwards I get an 'undefined reference to dlopen' error.
>>
>> If I run ./python setup.py --verbose -library-dirs /path/to/lib
>> --libraries='c dl m' -f, the 'undefined reference to dlopen' error is
>> thrown again.
>>
>> If I run ./python setup.py --verbose -library-dirs /path/to/lib
>> --libraries='-lc -ldl -lm' -f the build continues past _struct...even
>> though ld throws the expected 'unable to find -l-lc' and other errors.
>>
>> Let me know if you need me to provide additional information.  Any
>> help would be greatly appreciated.
>>
>> Cyd
>
>
> Additionally I took a strace of the error producing command. The
> following is (hopefully) a relevant portion minus the various 'no such
> file' lines before the correct lib is found (which it always is)
>
> 16513 
> open("/data/data/jackpal.androidterm/kbox2/bld/python/Python-2.7.8/Lib/distutils/unixccompiler.py",
> O_RDONLY|O_LARGEFILE) = 3   16513
> open("/data/data/jackpal.androidterm/kbox2/bld/python/Python-2.7.8/Lib/distutils/unixccompiler.pyc",
> O_RDONLY|O_LARGEFILE) = 4   16513 vfork()
>  = 16525
> 16513 wait4(16525,  
> 16525 open("/data/data/jackpal.androidterm/kbox2/bin/sh",
> O_RDONLY|O_LARGEFILE) = 3
> 16525 execve("/data/data/jackpal.androidterm/kbox2/bin/sh", ["sh",
> "-c", "gcc --sysroot=/usr/gcc-4.9.2/sysroot -print-multiarch >
> build/temp.linux-armv7l-2.7/multiarch 2> /dev/null"], [/* 58 vars */])
> = 0
>
> *snip call to libc intercepted by libfakechroot*
>
> 16525 open("/system/lib/libc.so", O_RDONLY|O_LARGEFILE|0x8) = 3
> 16525 open("/system/lib/libm.so", O_RDONLY|O_LARGEFILE|0x8) = 3
> 16525 open("/dev/__properties__",
> O_RDONLY|O_LARGEFILE|O_NOFOLLOW|0x8) = 3
> 16525 open("build/temp.linux-armv7l-2.7/multiarch",
> O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> 16525 open("/data/data/jackpal.androidterm/kbox2/dev/null",
> O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> 16525 fork()= 16526
> 16525 wait4(-1,  
> 16526 open("/acct/uid/10186/tasks", O_RDWR|O_CREAT|O_LARGEFILE, 0666)
> = -1 EACCES (Permission denied)
>
> See attached for remainder

Should I be posting this issue elsewhere?
Is more information needed?
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Undefined dlopen When Building Module On Android

2015-01-21 Thread Guido van Rossum
Maybe try a list focused on Android development? Few people in the Python
core development community have any Android experience. But the issues and
context you offer seem to be related to the Android world, not to Python.
(dlopen is used by a lot of systems, not just Python.)

On Wed, Jan 21, 2015 at 2:43 PM, Cyd Haselton  wrote:

> On Mon, Jan 19, 2015 at 5:23 PM, Cyd Haselton  wrote:
> > On Mon, Jan 19, 2015 at 8:51 AM, Cyd Haselton 
> wrote:
> >> Hello,
> >> I'm struggling with a build issue on Android; I've posted to the
> >> general python list with no result, so I'm re-posting here in hopes
> >> that someone can help.  If this is the wrong place feel free to let me
> >> know.
> >>
> >> I'm attempting to build Python 2.7.8 on my Android device; I'm using
> >> an environment that simulates a Linux filesystem within the Android
> >> terminal using a port of fakechroot.  Within that environment I've
> >> ported and/or bootstrapped a number of Linux utilities (curl, git,
> >> openssl, gcc)
> >>
> >> I run ./configure, then make, and the executable and library are
> >> built.  The problem occurs when build_ext is run; the newly built
> >> python executable builds, then links _struct, and immediately
> >> afterwards I get an 'undefined reference to dlopen' error.
> >>
> >> If I run ./python setup.py --verbose -library-dirs /path/to/lib
> >> --libraries='c dl m' -f, the 'undefined reference to dlopen' error is
> >> thrown again.
> >>
> >> If I run ./python setup.py --verbose -library-dirs /path/to/lib
> >> --libraries='-lc -ldl -lm' -f the build continues past _struct...even
> >> though ld throws the expected 'unable to find -l-lc' and other errors.
> >>
> >> Let me know if you need me to provide additional information.  Any
> >> help would be greatly appreciated.
> >>
> >> Cyd
> >
> >
> > Additionally I took a strace of the error producing command. The
> > following is (hopefully) a relevant portion minus the various 'no such
> > file' lines before the correct lib is found (which it always is)
> >
> > 16513
> open("/data/data/jackpal.androidterm/kbox2/bld/python/Python-2.7.8/Lib/distutils/unixccompiler.py",
> > O_RDONLY|O_LARGEFILE) = 3   16513
> >
> open("/data/data/jackpal.androidterm/kbox2/bld/python/Python-2.7.8/Lib/distutils/unixccompiler.pyc",
> > O_RDONLY|O_LARGEFILE) = 4   16513 vfork()
> >  = 16525
> > 16513 wait4(16525,  
> > 16525 open("/data/data/jackpal.androidterm/kbox2/bin/sh",
> > O_RDONLY|O_LARGEFILE) = 3
> > 16525 execve("/data/data/jackpal.androidterm/kbox2/bin/sh", ["sh",
> > "-c", "gcc --sysroot=/usr/gcc-4.9.2/sysroot -print-multiarch >
> > build/temp.linux-armv7l-2.7/multiarch 2> /dev/null"], [/* 58 vars */])
> > = 0
> >
> > *snip call to libc intercepted by libfakechroot*
> >
> > 16525 open("/system/lib/libc.so", O_RDONLY|O_LARGEFILE|0x8) = 3
> > 16525 open("/system/lib/libm.so", O_RDONLY|O_LARGEFILE|0x8) = 3
> > 16525 open("/dev/__properties__",
> > O_RDONLY|O_LARGEFILE|O_NOFOLLOW|0x8) = 3
> > 16525 open("build/temp.linux-armv7l-2.7/multiarch",
> > O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> > 16525 open("/data/data/jackpal.androidterm/kbox2/dev/null",
> > O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
> > 16525 fork()= 16526
> > 16525 wait4(-1,  
> > 16526 open("/acct/uid/10186/tasks", O_RDWR|O_CREAT|O_LARGEFILE, 0666)
> > = -1 EACCES (Permission denied)
> >
> > See attached for remainder
>
> Should I be posting this issue elsewhere?
> Is more information needed?
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Why does STORE_MAP not take a parameter?

2015-01-21 Thread Greg Ewing

On 01/21/2015 11:16 PM, Neil Girdhar wrote:

Why not have BUILD_MAP work like BUILD_LIST?   I.e., STORE_MAP takes a
parameter n and adds the last n pairs of stack elements into the n-1 stack
element (the dictionary).


It probably wouldn't make much difference. Building a list is
substantially cheaper if you have all the items on hand and can
copy them in en masse. But adding an item to a dict entails
quite a lot of overhead, since you need to hash the key, look
for a free slot, etc. and this would likely swamp any gain
from executing less bytecodes. And on the other side of the
equation, evaluating the items one at a time requires less
stack space, so the stack frame can be smaller.

But as always, you can't be sure without measuring it, and
this would be a good thing for someone interested to try out.

--
Greg

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com