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

  • SEARCH
  • Home
  • 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 7278839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:55:48+00:00 2026-05-28T22:55:48+00:00

Python has a lot of convenient data structures (lists, tuples, dicts, sets, etc) which

  • 0

Python has a lot of convenient data structures (lists, tuples, dicts, sets, etc) which can be used to make other ‘conventional’ data structures (Eg, I can use a Python list to create a stack and a collections.dequeue to make a queue, dicts to make trees and graphs, etc).

There are even third-party data structures that can be used for specific tasks (for instance the structures in Pandas, pytables, etc).

So, if I know how to use lists, dicts, sets, etc, should I be able to implement any arbitrary data structure if I know what it is supposed to accomplish?

In other words, what kind of data structures can the Python data structures not be used for?

Thanks

  • 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-28T22:55:49+00:00Added an answer on May 28, 2026 at 10:55 pm

    For some simple data structures (eg. a stack), you can just use the builtin list to get your job done. With more complex structures (eg. a bloom filter), you’ll have to implement them yourself using the primitives the language supports.

    You should use the builtins if they serve your purpose really since they’re debugged and optimised by a horde of people for a long time. Doing it from scratch by yourself will probably produce an inferior data structure. Whether you’re using Python, C++, C#, Java, whatever, you should always look to the built in data structures first. They will generally be implemented using the same system primitives you would have to use doing it yourself, but with the advantage of having been tried and tested.

    Combinations of these data structures (and maybe some of the functions from helper modules such as heapq and bisect) are generally sufficient to implement most richer structures that may be needed in real-life programming; however, that’s not invariably the case.

    Only when the provided data structures do not allow you to accomplish what you need, and there isn’t an alternative and reliable library available to you, should you be looking at building something from scratch (or extending what’s provided).

    Lets say that you need something more than the rich python library provides, consider the fact that an object’s attributes (and items in collections) are essentially “pointers” to other objects (without pointer arithmetic), i.e., “reseatable references”, in Python just like in Java. In Python, you normally use a None value in an attribute or item to represent what NULL would mean in C++ or null would mean in Java.

    So, for example, you could implement binary trees via, e.g.:

    class Node(object):
    
      __slots__ = 'data', 'left', 'right'
    
      def __init__(self, data=None, left=None, right=None):
        self.data  = data
        self.left  = left
        self.right = right
    

    plus methods or functions for traversal and similar operations (the __slots__ class attribute is optional — mostly a memory optimization, to avoid each Node instance carrying its own __dict__, which would be substantially larger than the three needed attributes/references).

    Other examples of data structures that may best be represented by dedicated Python classes, rather than by direct composition of other existing Python structures, include tries (see e.g. here) and graphs (see e.g. here).

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

Sidebar

Related Questions

I noticed that Python has quite a lot specialities for working with data structures
Python has a lot of GUI libraries: tkinter, wxWidgets, pyGTK etc. But all these
I'm starting on a new scientific project which has a lot of data (millions
Python has a flag -O that you can execute the interpreter with. The option
I know that python has a len() function that is used to determine the
Python language has a well known feature named interactive mode where the interpreter can
I have list in python which has following entries name-1 name-2 name-3 name-4 name-1
I write a lot of scripts in Python to analyze and plot experimental data
Has anybody come across an Enthought TraitsUI (Envisage etc) based Python IDE? I wonder
It seems that the unittest module has been changed a lot in Python 2.7

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.