On Tue, 23 Dec 2014 20:28:30 -0500, Dave Tian wrote:
> Hi,
>
> There are 2 statements:
> A: a = ‘h’
> B: b = ‘hh’
>
> According to me understanding, A should be faster as characters would
> shortcut this 1-byte string ‘h’ without malloc; B should be slower than
> A as characters does not work fo
Dave Tian wrote:
A: a = ‘h’
> B: b = ‘hh’
According to me understanding, A should be faster as characters would
shortcut this 1-byte string ‘h’ without malloc;
It sounds like you're expecting characters to be stored
"unboxed" like in Java.
That's not the way Python works. Objects are used
On Wed, Dec 24, 2014 at 4:22 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
> What happens here is that you time a piece of code to:
>
> - Build a large list containing 100 million individual int objects. Each
int
> object has to be allocated at run time, as does the list. Each
On 12/23/14 8:28 PM, Dave Tian wrote:
Hi,
There are 2 statements:
A: a = ‘h’
B: b = ‘hh’
According to me understanding, A should be faster as characters would shortcut
this 1-byte string ‘h’ without malloc; B should be slower than A as characters
does not work for 2-byte string ‘hh’, which tr
On 12/23/2014 08:28 PM, Dave Tian wrote:
Hi,
Hi, please do some things when you post new questions:
1) identify your Python version. In this case it makes a big
difference, as in Python 2.x, the range function is the only thing that
takes any noticeable time in this code.
2) when posting
Dave Tian wrote:
> Hi,
>
> There are 2 statements:
> A: a = ‘h’
> B: b = ‘hh’
>
> According to me understanding, A should be faster as characters would
> shortcut this 1-byte string ‘h’ without malloc; B should be slower than A
> as characters does not work for 2-byte string ‘hh’, which triggers
Hi,
There are 2 statements:
A: a = ‘h’
B: b = ‘hh’
According to me understanding, A should be faster as characters would shortcut
this 1-byte string ‘h’ without malloc; B should be slower than A as characters
does not work for 2-byte string ‘hh’, which triggers the malloc. However, when
I put