Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create instance for arrays #9

Open
dineshbvadhia opened this issue Aug 21, 2024 · 0 comments
Open

Create instance for arrays #9

dineshbvadhia opened this issue Aug 21, 2024 · 0 comments

Comments

@dineshbvadhia
Copy link

dineshbvadhia commented Aug 21, 2024

I've got pond working but it is not recycling correctly plus I'm not convinced the instance creation is optimal for my use case. The pool is for 3 numpy arrays:

np.array([1, 2])
np.array([5, 7])
np.array([3, 9]

A dictionary is created to hold the arrays:

def createInstance(self) -> PooledObject:
	d = {0:np.array([1, 2]), 1:np.array([5, 7]), 2:np.array([3, 9]}
	return PooledObject(d)

To access a relevant array, index into the pooling_object (the dictionary). A taken array must not be recycled because it changes and instead a new array should be created.

The test results show the indexed array is being recycled instead of creating a new one. Both pooled_maxsize=3 and pooled_maxsize=1 return the same results.

Does this dictionary method recreate the taken array or the whole dictionary of arrays?

Is this the best way to create an instance for the 3 numpy arrays?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant