Comparison with Named Tuples - Deepstash
Machine Learning With Google

Learn more about computerscience with this collection

Understanding machine learning models

Improving data analysis and decision-making

How Google uses logic in machine learning

Machine Learning With Google

Discover 95 similar ideas in

It takes just

14 mins to read

Comparison with Named Tuples

Comparison with Named Tuples

  • Dataclasses are by default mutable
  • Named Tuples have methods which start with an underscore which can be confusing. Ex: obj._replace(f=value)
  • Named Tuples have legacy code. Ex: _asdict() returns an OrderedDict
  • Named Tuples can be unpacked
  • Dataclasses are faster at retrieving data but take up more space
  • Dataclasses use functions instead of methods. Ex: asdict() vs nt._asdict()
  • Dataclasses are underlying stored as instance dicts

6

20 reads

MORE IDEAS ON THIS

Dataclasses & What are they for

Dataclasses & What are they for

Dataclasses are an implementation of a code generator, similar to a Named Tuple.

The idea of using a code generator is to save time and reduce wordiness.

There are two views about the purpose of Dataclasses:

  1. It makes a mutable da...

6

39 reads

A Complex Example of using Dataclasses

A Complex Example of using Dataclasses

In the image example, the generated code includes:

  • typed attributes
  • hidden attributes from __repr__ response
  • custom __hash__ dunder with the selected fields
  • attribute with default factory value in __init__ constructor

6

29 reads

Generated Code Includes

  • Dunder methods like init, repr, eq, lt, le, etc.
  • Frozen nature by generating dunder methods for __setattr__ and __delattr__
  • Class variables for the provided attributes

The code generation can be configured by providing keyword a...

6

19 reads

RAYMOND HETTINGER

If you have an immutable mind get out!

RAYMOND HETTINGER

6

39 reads

A History Lesson

A History Lesson

In the beginning there where:

  • dicts for look-ups
  • tuples for structures
  • hand-written classes for more functionality

Later Named Tuples where added as a code generator with the goal of adding ...

6

27 reads

CURATED FROM

CURATED BY

pvl

Backend @deepstash

I started using Dataclasses and I think you should too

β€œ

Related collections

More like this

Being intentional with our focus

Being intentional with our focus

While today's technologies have many advantages, we have to learn to be more intentional about focusing – for instance, carving out space in our day when we can concentrate without such distractions.

We also need to strengthen our focus. It works like a muscle: there are workouts ...

stash-superman-illustration

Explore the World’s

Best Ideas

200,000+ ideas on pretty much any topic. Created by the smartest people around & well-organized so you can explore at will.

An Idea for Everything

Explore the biggest library of insights. And we've infused it with powerful filtering tools so you can easily find what you need.

Knowledge Library

Powerful Saving & Organizational Tools

Save ideas for later reading, for personalized stashes, or for remembering it later.

# Personal Growth

Take Your Ideas

Anywhere

Organize your ideas & listen on the go. And with Pro, there are no limits.

Listen on the go

Just press play and we take care of the words.

Never worry about spotty connections

No Internet access? No problem. Within the mobile app, all your ideas are available, even when offline.

Get Organized with Stashes

Ideas for your next work project? Quotes that inspire you? Put them in the right place so you never lose them.

Join

2 Million Stashers

4.8

5,740 Reviews

App Store

4.7

72,690 Reviews

Google Play

samz905

Don’t look further if you love learning new things. A refreshing concept that provides quick ideas for busy thought leaders.

β€œ

Shankul Varada

Best app ever! You heard it right. This app has helped me get back on my quest to get things done while equipping myself with knowledge everyday.

β€œ

Ashley Anthony

This app is LOADED with RELEVANT, HELPFUL, AND EDUCATIONAL material. It is creatively intellectual, yet minimal enough to not overstimulate and create a learning block. I am exceptionally impressed with this app!

β€œ

Sean Green

Great interesting short snippets of informative articles. Highly recommended to anyone who loves information and lacks patience.

β€œ

Jamyson Haug

Great for quick bits of information and interesting ideas around whatever topics you are interested in. Visually, it looks great as well.

β€œ

Laetitia Berton

I have only been using it for a few days now, but I have found answers to questions I had never consciously formulated, or to problems I face everyday at work or at home. I wish I had found this earlier, highly recommended!

β€œ

Giovanna Scalzone

Brilliant. It feels fresh and encouraging. So many interesting pieces of information that are just enough to absorb and apply. So happy I found this.

β€œ

Ghazala Begum

Even five minutes a day will improve your thinking. I've come across new ideas and learnt to improve existing ways to become more motivated, confident and happier.

β€œ

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Access to 200,000+ ideas

β€”

Access to the mobile app

β€”

Unlimited idea saving & library

β€”

β€”

Unlimited history

β€”

β€”

Unlimited listening to ideas

β€”

β€”

Downloading & offline access

β€”

β€”

Personalized recommendations

β€”

β€”

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates