Nathaniel Smith wrote:
> This should be pretty trivial to implement. AFAICT you don't need any
> complicated cython
I have a bad habit of thinking in terms of too complicated C instead of
just using NumPy.
> @contextmanager
> def tmp_zeros(*args, **kwargs):
> arr = np.zeros(*args, **kwargs
Nathaniel Smith wrote:
> @contextmanager
> def tmp_zeros(*args, **kwargs):
> arr = np.zeros(*args, **kwargs)
> try:
> yield arr
> finally:
> arr.resize((0,), check_refs=False)
That one is interesting. I have actually never used ndarray.resize(). It
did not even occur
On 9 Dec 2014 15:03, "Sturla Molden" wrote:
>
>
> I wonder if ndarray should be a context manager so we can write
> something like this:
>
>
> with np.zeros(n) as x:
>[...]
>
>
> The difference should be that __exit__ should free the memory in x (if
> owned by x) and make x a zero size
Chris Barker wrote:
> my first thought iust that you can just do:
>
> x = np.zeros(n)
> [... your code here ]
> del x
>
> x's ref count will go down, and it will be deleted if there are no other
> references to it.
1. This depends on reference counting. PyPy supports numpy too (albeit with
On Tue, Dec 9, 2014 at 8:15 PM, Chris Barker wrote:
>
> (although I'm still confused as to why it's so important (in cPython) to
> have a file context manager..)
>
Because you want the file to close when the exception is raised and not at
some indeterminate point thereafter when the traceback sta
On Tue, Dec 9, 2014 at 7:01 AM, Sturla Molden
wrote:
>
> I wonder if ndarray should be a context manager so we can write
> something like this:
>
>
> with np.zeros(n) as x:
>[...]
>
>
> The difference should be that __exit__ should free the memory in x (if
> owned by x) and make x a z
On Tue, Dec 9, 2014 at 5:57 PM, Julian Taylor
wrote:
>
> On 09.12.2014 18:55, Sturla Molden wrote:
> > On 09/12/14 18:39, Julian Taylor wrote:
> >
> >> A context manager will also not help you with reference cycles.
> >
> > If will because __exit__ is always executed. Even if the PyArrayObject
> >
On 09.12.2014 18:55, Sturla Molden wrote:
> On 09/12/14 18:39, Julian Taylor wrote:
>
>> A context manager will also not help you with reference cycles.
>
> If will because __exit__ is always executed. Even if the PyArrayObject
> struct lingers, the data buffer will be released.
>
a exit func
On 09/12/14 18:39, Julian Taylor wrote:
> A context manager will also not help you with reference cycles.
If will because __exit__ is always executed. Even if the PyArrayObject
struct lingers, the data buffer will be released.
Sturla
___
NumPy-Discu
I don't think that makes much sense, context managers are useful for
managing the lifetime of objects owning resources not already managed by
the garbage collector.
E.g. file descriptors, a gc has no clue that a piece of memory contains
a descriptor and thus never has a reason to release it in time
As the question asks:
should `unpackbits` add a dtype argument?
At the moment I'm interest in unpacking as a boolean array.
Alan Isaac
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Hi,
Le 08/12/2014 22:02, Jose Guzman a écrit :
> I'm trying to compute the cross correlation and cross correlograms from
> some signals. For that, I'm testing first np.correlate with some
> idealized traces (sine waves) that are exactly 1 ms separated from each
> other. You can have a look here:
My impression is that this level of optimization does and should not fall
within the scope of numpy..
-Original Message-
From: "Sturla Molden"
Sent: 9-12-2014 16:02
To: "numpy-discussion@scipy.org"
Subject: [Numpy-discussion] Should ndarray be a context manager?
I wonder if ndarra
I wonder if ndarray should be a context manager so we can write
something like this:
with np.zeros(n) as x:
[...]
The difference should be that __exit__ should free the memory in x (if
owned by x) and make x a zero size array.
Unlike the current ndarray, which does not have an __
14 matches
Mail list logo