Re: Why can't numpy array be restored to saved value?

2020-11-26 Thread Christian Gollwitzer

Am 25.11.20 um 07:47 schrieb [email protected]:

Why isn't the final value of the numpy array npary in the following code the
same as the initial value before some but not all elements of the array were
changed to a new value?

I know I am missing something basic here.  I thought I understood the
concepts of immutable vs mutable values but obviously I missed something.

My environment is Win10-64, Python 3.8.5, numpy 1.19.2.

Code and output follows.  TIA for any help you can provide to cure my
ignorance.

Peter

--- nptest.py ---
import numpy as np
import sys

if len(sys.argv) > 0:
 try:
 asz = int(sys.argv[1]) + 0
 except:
 asz = 4

npary = np.full([asz, asz, asz], 0, dtype=np.int32)
print("Array before change=\n{}".format(npary))
svary = npary[:, :, :]


Because this does not copy the array, rather it creates a view into the 
original array. This is an optimization to avoid copying. If you want a 
copy, do svary = npary.copy()


Christian
--
https://mail.python.org/mailman/listinfo/python-list


RE: Why can't numpy array be restored to saved value?

2020-11-26 Thread pjfarley3
> -Original Message-
> From: Greg Ewing 
> Sent: Thursday, November 26, 2020 12:01 AM
> To: [email protected]
> Subject: Re: Why can't numpy array be restored to saved value?
> 
> On 25/11/20 7:47 pm, [email protected] wrote:
> > Why isn't the final value of the numpy array npary in the following code the
> > same as the initial value before some but not all elements of the array were
> > changed to a new value?
> 
> Slicing a numpy array doesn't copy anything, it just
> gives you another view of the underlying data.
> 
> This is a trap you need to watch out for, since it's
> different from the way sequences normally behave in
> Python.
> 
> --
> Greg

Thank you for that explanation.  I will certainly watch out for it in the 
future.

Peter

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Why can't numpy array be restored to saved value?

2020-11-26 Thread pjfarley3
> -Original Message-
> From: Christian Gollwitzer 
> Sent: Thursday, November 26, 2020 3:26 AM
> To: [email protected]
> Subject: Re: Why can't numpy array be restored to saved value?
> 
> Am 25.11.20 um 07:47 schrieb [email protected]:
> > Why isn't the final value of the numpy array npary in the following code the
> > same as the initial value before some but not all elements of the array were
> > changed to a new value?
> >
> > I know I am missing something basic here.  I thought I understood the
> > concepts of immutable vs mutable values but obviously I missed something.
> >

> 
> Because this does not copy the array, rather it creates a view into the
> original array. This is an optimization to avoid copying. If you want a
> copy, do svary = npary.copy()

Thank you for the explanation.  I did indeed find that using the copy() 
function did what I needed to do.

Peter

-- 
https://mail.python.org/mailman/listinfo/python-list


[RELEASE] Python 3.9.1rc1 is now ready for testing

2020-11-26 Thread Łukasz Langa
Python 3.9.1rc1 is the release candidate of the first maintenance release of 
Python 3.9. Go get it here:
https://www.python.org/downloads/release/python-391rc1/ 

Assuming no critical problems are found prior to 2020-12-11, the currently 
scheduled release date for 3.9.1, no code changes are planned between this 
release candidate and the final release. That being said, please keep in mind 
that this is a pre-release of 3.9.1 and as such its main purpose is testing.

Maintenance releases for the 3.9 series will continue at regular bi-monthly 
intervals, with 3.9.2 planned for end of January 2021.

Installer news

3.9.1rc1 is the first version of Python to support macOS 11 Big Sur. With Xcode 
11 and later it is now possible to build “Universal 2” binaries which work on 
Apple Silicon. We are providing such an installer as the macosx11.0 variant. 
This installer can be deployed back to older versions, tested down to OS X 
10.9. As we are waiting for an updated version of pip, please consider the 
macosx11.0 installer experimental.

This work would not have been possible without the effort of Ronald Oussoren, 
Ned Deily, and Lawrence D’Anna from Apple. Thank you!

In other news, this is the first version of Python to default to the 64-bit 
installer on Windows. The installer now also actively disallows installation on 
Windows 7. Python 3.9 is incompatible with this unsupported version of Windows.

What’s new in Python 3.9.1rc1?

We’ve made 240 changes since v3.9.0 which is a significant amount. To compare, 
3.8.1rc1 only saw 168 commits since 3.8.0. See the full change log at

https://docs.python.org/release/3.9.1rc1/whatsnew/changelog.html 
.

For more information about features included in the 3.9 series, see the “What’s 
New in Python 3.9 ” 
document.

What about Python 3.8.7rc1?

There’s additional work needed to make this release support macOS 11 Big Sur. 
This should be ready next week, stay tuned.

We hope you enjoy the new releases!

Thanks to all of the many volunteers who help make Python Development and these 
releases possible! Please consider supporting our efforts by volunteering 
yourself or through organization contributions to the Python Software 
Foundation.

https://www.python.org/psf/ 
More resources

Online Documentation 
PEP 596 , 3.9 Release Schedule
PEP 619 , 3.10 Release Schedule
Report bugs at https://bugs.python.org .
Help fund Python and its community .
Your friendly release team,
Ned Deily @nad 
Steve Dower @steve.dower 
Łukasz Langa @ambv 
-- 
https://mail.python.org/mailman/listinfo/python-list