Re: [Numpy-discussion] script for building numpy from source in virtualenv and outside it

2016-12-26 Thread Ralf Gommers
On Tue, Dec 27, 2016 at 9:43 AM, Felipe Vieira  wrote:

> Dear fellows,
>
> I'm struggling with a single script to build numpy from source in a
> virtual env. I want the same script to be able to be run with a normal env.
>
> So if ran from a normal env it should affect all users.
> If ran within a virtual env the installation should be constrained to that
> env.
>
> I tried setting script variables and other tricks but the script is always
> executed as a 'out of virtual env' user (I cannot make it aware that is
> running from a virtualenv), thus affecting my real working python. As the
> script activates other scripts I am not posting them for now (hoping that
> this is a simple issue).
>
> tl;dr: How can I install numpy from source and build it in a script which
> uses the virtual env instead of affecting the whole system?
>
> (And yes, I have looked for solutions on google but none of them worked.)
>

Sounds like you just need to run your script with the Python interpreter in
the virtualenv. There's nothing numpy-specific about this.

Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] script for building numpy from source in virtualenv and outside it

2016-12-26 Thread Felipe Vieira
Dear fellows,

I'm struggling with a single script to build numpy from source in a virtual
env. I want the same script to be able to be run with a normal env.

So if ran from a normal env it should affect all users.
If ran within a virtual env the installation should be constrained to that
env.

I tried setting script variables and other tricks but the script is always
executed as a 'out of virtual env' user (I cannot make it aware that is
running from a virtualenv), thus affecting my real working python. As the
script activates other scripts I am not posting them for now (hoping that
this is a simple issue).

tl;dr: How can I install numpy from source and build it in a script which
uses the virtual env instead of affecting the whole system?

(And yes, I have looked for solutions on google but none of them worked.)

Best regards,
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Casting to np.byte before clearing values

2016-12-26 Thread Benjamin Root
Might be os-specific, too. Some virtual memory management systems might
special case the zeroing out of memory. Try doing the same thing with a
different value than zero.

On Dec 26, 2016 6:15 AM, "Nicolas P. Rougier" 
wrote:


Thanks for the explanation Sebastian, makes sense.

Nicolas


> On 26 Dec 2016, at 11:48, Sebastian Berg 
wrote:
>
> On Mo, 2016-12-26 at 10:34 +0100, Nicolas P. Rougier wrote:
>> Hi all,
>>
>>
>> I'm trying to understand why viewing an array as bytes before
>> clearing makes the whole operation faster.
>> I imagine there is some kind of special treatment for byte arrays but
>> I've no clue.
>>
>
> Sure, if its a 1-byte width type, the code will end up calling
> `memset`. If it is not, it will end up calling a loop with:
>
> while (N > 0) {
> *dst = output;
> *dst += 8;  /* or whatever element size/stride is */
> --N;
> }
>
> now why this gives such a difference, I don't really know, but I guess
> it is not too surprising and may depend on other things as well.
>
> - Sebastian
>
>
>>
>> # Native float
>> Z_float = np.ones(100, float)
>> Z_int   = np.ones(100, int)
>>
>> %timeit Z_float[...] = 0
>> 1000 loops, best of 3: 361 µs per loop
>>
>> %timeit Z_int[...] = 0
>> 1000 loops, best of 3: 366 µs per loop
>>
>> %timeit Z_float.view(np.byte)[...] = 0
>> 1000 loops, best of 3: 267 µs per loop
>>
>> %timeit Z_int.view(np.byte)[...] = 0
>> 1000 loops, best of 3: 266 µs per loop
>>
>>
>> Nicolas
>> ___
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> https://mail.scipy.org/mailman/listinfo/numpy-discussion
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Casting to np.byte before clearing values

2016-12-26 Thread Nicolas P. Rougier

Thanks for the explanation Sebastian, makes sense.

Nicolas


> On 26 Dec 2016, at 11:48, Sebastian Berg  wrote:
> 
> On Mo, 2016-12-26 at 10:34 +0100, Nicolas P. Rougier wrote:
>> Hi all,
>> 
>> 
>> I'm trying to understand why viewing an array as bytes before
>> clearing makes the whole operation faster.
>> I imagine there is some kind of special treatment for byte arrays but
>> I've no clue. 
>> 
> 
> Sure, if its a 1-byte width type, the code will end up calling
> `memset`. If it is not, it will end up calling a loop with:
> 
> while (N > 0) {
> *dst = output;
> *dst += 8;  /* or whatever element size/stride is */
> --N;
> }
> 
> now why this gives such a difference, I don't really know, but I guess
> it is not too surprising and may depend on other things as well.
> 
> - Sebastian
> 
> 
>> 
>> # Native float
>> Z_float = np.ones(100, float)
>> Z_int   = np.ones(100, int)
>> 
>> %timeit Z_float[...] = 0
>> 1000 loops, best of 3: 361 µs per loop
>> 
>> %timeit Z_int[...] = 0
>> 1000 loops, best of 3: 366 µs per loop
>> 
>> %timeit Z_float.view(np.byte)[...] = 0
>> 1000 loops, best of 3: 267 µs per loop
>> 
>> %timeit Z_int.view(np.byte)[...] = 0
>> 1000 loops, best of 3: 266 µs per loop
>> 
>> 
>> Nicolas
>> ___
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> https://mail.scipy.org/mailman/listinfo/numpy-discussion
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Casting to np.byte before clearing values

2016-12-26 Thread Sebastian Berg
On Mo, 2016-12-26 at 10:34 +0100, Nicolas P. Rougier wrote:
> Hi all,
> 
> 
> I'm trying to understand why viewing an array as bytes before
> clearing makes the whole operation faster.
> I imagine there is some kind of special treatment for byte arrays but
> I've no clue. 
> 

Sure, if its a 1-byte width type, the code will end up calling
`memset`. If it is not, it will end up calling a loop with:

while (N > 0) {
    *dst = output;
    *dst += 8;  /* or whatever element size/stride is */
    --N;
}

now why this gives such a difference, I don't really know, but I guess
it is not too surprising and may depend on other things as well.

- Sebastian


> 
> # Native float
> Z_float = np.ones(100, float)
> Z_int   = np.ones(100, int)
> 
> %timeit Z_float[...] = 0
> 1000 loops, best of 3: 361 µs per loop
> 
> %timeit Z_int[...] = 0
> 1000 loops, best of 3: 366 µs per loop
> 
> %timeit Z_float.view(np.byte)[...] = 0
> 1000 loops, best of 3: 267 µs per loop
> 
> %timeit Z_int.view(np.byte)[...] = 0
> 1000 loops, best of 3: 266 µs per loop
> 
> 
> Nicolas
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion

signature.asc
Description: This is a digitally signed message part
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Casting to np.byte before clearing values

2016-12-26 Thread Nicolas P. Rougier

Hi all,


I'm trying to understand why viewing an array as bytes before clearing makes 
the whole operation faster.
I imagine there is some kind of special treatment for byte arrays but I've no 
clue. 


# Native float
Z_float = np.ones(100, float)
Z_int   = np.ones(100, int)

%timeit Z_float[...] = 0
1000 loops, best of 3: 361 µs per loop

%timeit Z_int[...] = 0
1000 loops, best of 3: 366 µs per loop

%timeit Z_float.view(np.byte)[...] = 0
1000 loops, best of 3: 267 µs per loop

%timeit Z_int.view(np.byte)[...] = 0
1000 loops, best of 3: 266 µs per loop


Nicolas
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion