Attention Is a Data Structure: What ADHD and Python Teach Us About Focus
Hatched by Alessio Frateily
May 24, 2026
10 min read
3 views
72%
The hidden question behind focus
What if attention is not a feeling, a trait, or even a single skill, but a system for managing information?
That question changes everything. It suggests that when someone says they cannot focus, they may not be describing a lack of willpower at all. They may be describing a system that is struggling to sort, store, prioritize, and switch between inputs fast enough for the task at hand. In that sense, attention is less like a spotlight and more like a computer architecture problem.
This is where an unexpected comparison becomes useful. In Python, different collection types exist for different jobs. A list is ordered and flexible. A tuple is ordered and fixed. A set removes duplicates and ignores order. A dictionary stores key value pairs for fast lookup. None of these is inherently better than the others. Each embodies a tradeoff between structure, speed, flexibility, and change.
The brain works with a similar logic. Attention is not one thing. It includes suppressing irrelevant noise, amplifying what matters, and shifting between competing demands. The prefrontal cortex helps orchestrate those operations. Stimulants can be effective because they do not simply add energy, they often improve the brain’s ability to organize attention as a system.
That is the deeper connection: both cognition and code are governed by structure, and structure determines what can be held, ignored, retrieved, or changed.
Why focus fails when the mind has the wrong container
Most people think distraction happens because they are weak. In practice, distraction often happens because the mind is using the wrong internal container for the job.
Imagine trying to keep track of a grocery list, a work deadline, and a half remembered idea from a meeting all in the same mental space. If every item is treated as equally urgent, attention becomes a cluttered list with no indexing, no hierarchy, and no separation between signal and noise. You are not failing to care. You are trying to run a complex process in an underspecified format.
Python makes this easy to see. If you need to preserve sequence, you use a list or tuple. If you need uniqueness, you use a set. If you need rapid retrieval by meaning rather than position, you use a dictionary. The choice of structure changes the behavior of the whole system.
Attention works the same way. A brain trying to write an essay, answer messages, and anticipate tomorrow’s meeting may need to shift some items into a more stable container, some into a temporary scratchpad, and some into a retrieval system. The problem is not merely how much information exists. The problem is how it is represented.
That is why attention can feel so slippery. If your mind keeps everything in one undifferentiated stream, then every new cue competes with every existing thought. A passing notification, an internal worry, and the first sentence of your paragraph all occupy the same stage. No wonder focus collapses.
A useful mental model is this: distraction often means poor data architecture.
When a system has no clear rules for what belongs where, it wastes energy deciding what to do next. The same is true for the mind. Much of what we call procrastination may actually be unresolved categorization: Is this important now, later, or not at all?
The brain does not need more effort, it needs better orchestration
Attention is commonly imagined as a beam. In reality, it is closer to an orchestra conductor. Some neural processes need to quiet down while others are brought forward. Some signals must be amplified. Others must be suppressed. Task switching requires a different coordination pattern than deep concentration. Even multitasking, to the extent it is possible, means juggling covert attention rather than doing two things with equal clarity.
This is where the prefrontal cortex matters. It helps orchestrate which circuits become more or less active at a given moment. In practical terms, it helps answer questions like: What is relevant right now? What should be ignored? What should be held in working memory? What should be deferred?
That orchestration is expensive. The more competing inputs there are, the more costly the process becomes. This is why a person can seem perfectly capable in a calm room but fall apart in a chaotic one. The issue is not intelligence. It is the cost of maintaining structure under load.
Here again the Python analogy clarifies something subtle. A dictionary can retrieve a value by key efficiently, but only if the key is well defined. A set efficiently tells you what is present and what is not, but it throws away order. A tuple preserves structure but resists change. Each collection type imposes a discipline on data.
Likewise, attention improves when life is organized into usable categories. If every task is stored in the same mental bucket, the brain must repeatedly sort and resort. If tasks are grouped by mode, context, or urgency, the system becomes easier to run. This is one reason checklists, routines, and external note systems are so effective. They are not crutches. They are architectural aids.
Focus is not just the power to hold one thing in mind. It is the ability to give different kinds of information different kinds of containers.
That reframes many everyday struggles. If you cannot focus, you may not need more motivation first. You may need a better structure for your attention.
Why stimulants work, and why that is more interesting than it sounds
The popularity of stimulants often gets discussed as though the central question is whether they make people sharper. That is too narrow. The more interesting question is why changing brain chemistry can so dramatically improve an ability that feels moral, personal, and identity based.
The answer becomes clearer when attention is understood as coordination. Stimulants can help the brain suppress irrelevant noise, ramp up task relevant signals, and stabilize the system long enough for complex operations to occur. In other words, they can improve the efficiency of selection.
That does not mean they create excellence from nothing. A stimulant cannot replace judgment, training, or good task design. What it can do is reduce the friction between intention and execution. For someone whose attention system is underperforming, that can feel like the difference between a room full of static and a room with a usable signal.
Here is the analogy to Python. If a collection is poorly suited to the operation you need, no amount of trying harder will make it optimal. You can search through a list, but if fast lookup matters, a dictionary is better. You can preserve order in a list, but if uniqueness is the key requirement, a set is better. The improvement comes not from moral effort, but from using the right structure for the task.
That is why stimulant treatment can feel, for many people, less like being artificially pushed and more like being returned to a workable internal architecture. It does not magically solve life. It helps the system execute the logic that was already there.
This also explains why some people misuse the idea of productivity chemicals. They assume more stimulation automatically means more focus. But there is a limit. Overactivation can create a different kind of noise, one that makes the system more energetic but less precise. A brain can become so revved up that it loses the ability to distinguish a real signal from a compelling distraction.
The lesson is not that stimulants are good or bad in the abstract. The lesson is that attention is a regulated system, not a volume knob.
The real productivity question: what should be mutable?
Python’s distinction between mutable and immutable objects gives us a surprisingly powerful framework for thinking about mental life. Some things should be changeable, and some should not. Productivity suffers when everything is treated as mutable, because the system never settles. Productivity also suffers when everything is treated as immutable, because the system cannot adapt.
The mind faces the same tradeoff. Some thoughts need to be editable: plans, drafts, hypotheses, schedules. Others need to remain stable: values, commitments, definitions of success. If every idea is perpetually negotiable, you will experience decision fatigue. If nothing can be revised, you will become rigid and unable to respond to new information.
This suggests a practical question that is often missing from advice about focus:
Which parts of your day should be lists, which should be tuples, which should be sets, and which should be dictionaries?
Here is one way to translate that into life:
- Use a list for tasks that must be done in sequence, such as a morning routine or a step by step project.
- Use a tuple for commitments you want to protect from constant revision, such as your core priorities for the quarter.
- Use a set for repeated inputs where uniqueness matters, such as recurring mistakes or duplicated obligations.
- Use a dictionary for information you need to retrieve quickly by category, such as contact info, reference notes, or project files.
This is not just a cute metaphor. It points to a discipline of cognition: match mental structure to task type.
A person with attention difficulties often tries to solve everything with the equivalent of a list. Every task is an item in a linear stream, equally loud and equally urgent. But the brain is not built to treat all inputs as identical. It wants categorization, salience, and hierarchy. When those are missing, the mind pays a tax in constant re evaluation.
The same is true at work. Meetings, messages, deadlines, and creative work cannot all live in the same mental container. If they do, you will spend the whole day switching contexts instead of making progress. The solution is not to become superhuman. It is to build better containers.
The practical synthesis: build an attention architecture
The most useful conclusion from this synthesis is that focus is not mainly a test of character. It is an architecture problem.
An attention architecture has three parts:
- Filtering: what gets excluded.
- Indexing: what gets categorized and stored for retrieval.
- Scheduling: what gets priority now versus later.
Most productivity advice overemphasizes scheduling. People make to do lists and calendars, but they do not filter well, and they do not index their obligations intelligently. That is why even highly organized people can feel overwhelmed. They are managing more items, but not necessarily building a better system.
Consider a writer. She cannot draft well if every concern arrives at once: the opening sentence, the next paragraph, the research question, the email she forgot, the fear that the piece will fail. Instead, she needs a system. Drafting belongs in one mode, note taking in another, housekeeping in a third. The act of writing improves when the mind stops trying to use one container for everything.
This is also why external tools matter so much. A notebook, task manager, or whiteboard is not just memory support. It is a way of changing the data structure of thought. By moving some information out of working memory and into an external system, you free the prefrontal cortex to do higher order orchestration instead of constant bookkeeping.
That may be the deepest lesson here: people are not born with fixed attention capacities in the simplistic sense. They operate within systems, internal and external, that either help or hinder the brain’s ability to sort reality.
The goal is not to force the mind to hold more. The goal is to make the mind hold the right things in the right way.
Key Takeaways
- Treat distraction as a design problem, not just a discipline problem. Ask what kind of container your thoughts are currently living in.
- Separate noise from signal deliberately. Use routines, notes, and environments that reduce irrelevant inputs before they compete for attention.
- Match the structure to the task. Some goals need sequence, some need stability, some need retrieval, and some need simple exclusion of duplicates.
- Use external systems to protect working memory. Writing things down is not a weakness. It is an architectural upgrade.
- Think of focus as orchestration. The aim is not to push harder, but to coordinate better.
Conclusion: attention is not the thing itself, it is the shape around the thing
We usually talk about focus as if it were an inner flame that must be kept alive by effort. But that picture is incomplete. Attention is closer to a shape that makes information usable. It is the difference between a pile of objects and a well organized system. It is the difference between raw data and a structure that can act on data.
That is why the comparison between brain networks and Python collections is more than a clever metaphor. Both reveal the same truth: performance depends on the rules of organization. The right structure can make a system feel intelligent, calm, and responsive. The wrong structure makes it feel noisy, expensive, and chaotic.
So the next time you struggle to focus, ask a more interesting question than, “Why am I so lazy?” Ask instead: What kind of container is my mind using right now, and is it the right one for this task?
That question may not just improve productivity. It may change the way you understand your own mind.
Sources
Hatch New Ideas with Glasp AI 🐣
Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)
Start Hatching 🐣