Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6995417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:01:14+00:00 2026-05-27T20:01:14+00:00

I have a numpy array that I would like to share between a bunch

  • 0

I have a numpy array that I would like to share between a bunch of python processes in a way that doesn’t involve copies. I create a shared numpy array from an existing numpy array using the sharedmem package.

import sharedmem as shm
def convert_to_shared_array(A):
    shared_array = shm.shared_empty(A.shape, A.dtype, order="C")
    shared_array[...] = A
    return shared_array

My problem is that each subprocess needs to access rows that are randomly distributed in the array. Currently I create a shared numpy array using the sharedmem package and pass it to each subprocess. Each process also has a list, idx, of rows that it needs to access. The problem is in the subprocess when I do:

#idx = list of randomly distributed integers

local_array = shared_array[idx,:]

# Do stuff with local array

It creates a copy of the array instead of just another view. The array is quite large and manipulating it first before shareing it so that each process accesses a contiguous range of rows like

local_array = shared_array[start:stop,:]

takes too long.

Question: What are good solutions for sharing random access to a numpy array between python processes that don’t involve copying the array?

The subprocesses need readonly access (so no need for locking on access).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:01:14+00:00Added an answer on May 27, 2026 at 8:01 pm

    Fancy indexing induces a copy, so you need to avoid fancy indexing if you want to avoid copies there is no way around it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NxM array in numpy that I would like to take the
I have a numpy array that contains some image data. I would like to
I have a Numpy array that looks like >>> a array([[ 3. , 2.
I would like to create a function that returns a numpy array if one
I have hundreds of thousands of NumPy boolean arrays that I would like to
I have a one dimensional NumPy array: a = numpy.array([2,3,3]) I would like to
I have a Numpy rec array from which I would like to do some
I have a NumPy array [1,2,3,4,5,6,7,8,9,10,11,12,13,14] and want to have an array structured like
I have a matrix in the type of a Numpy array. How would I
how do I calculate that an array of python numpy or me of all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.