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 7600715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:58:46+00:00 2026-05-30T22:58:46+00:00

I need to write a plugin for an application which is extensible using Python

  • 0

I need to write a plugin for an application which is extensible using Python 2.7. It needs to execute a rather complex dynamic algorithm which works on a rectangular matrix of integers.

The default Python installation that comes with that application does not include a numeric library like numpy, so unfortunately I have to implement this using only the Python stdlib.

I’ve tried several different approaches to represent the matrix in memory:

values = defaultdict(int)
values = [[0 for _ in range(width)] for _ in range(height)]
values = [0] * (width * height)   # access like values[j*width + i] later
values = [[0] * width for _ in range(height)]

The dict approach is only there for completeness, it’s actually not good performing because every element is accessed.

From my measurements, the last of these seems the fastest to build and access. However, I am surprised that there is no built-in matrix functionality. From what I have learned about Python so far, if you don’t find some obvious functionality in the stdlib, the most likely reason is that you haven’t looked hard enough.

So I wonder whether this can be optimized even further. For example using the array module or some other feature that I’m not aware of.

  • 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-30T22:58:47+00:00Added an answer on May 30, 2026 at 10:58 pm

    The array module might be faster when the matrix gets large, because it can pack values more compactly; it can be used with the values[j*width + i] convention. But no, there’s no multidimensional array in the Python standard library, probably because (a) Numpy already fills that niche effectively and (b) you can always make a list of lists if performance is not paramount.

    The fastest option really depends on the algorithm. The dict-based approach might actually be the fastest when the matrices you’re handling are very sparse (which in DP algorithms they’re usually not, at least not in the ones I saw).

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

Sidebar

Related Questions

I need to write an application in VB6 which makes a scatter plot out
I need to write a plugin for Dynamics CRM 4.0 that executes when a
I need to write, in JavaScript (I am using jQuery), a function that is
I need to write a large amount of data in my application. Data arrive
I need to write a python script that makes multiple HTTP requests to the
I need an Android application which should be able to fetch data from the
I want to write a php application using Zend Framework 2 (just the beta
I am writing an installer using Wix 3 which installs a plugin to a
I need to make a desktop app which is pretty complex and handles a
I have an existing django application, with which I need to integrate django-cms. Django-cms

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.