Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
## 2024-05-09 - Redundant attributes in Python ipaddress
**Learning:** By definition in Python's `ipaddress` module, `is_private`, `is_loopback`, `is_link_local`, `is_unspecified`, and `is_reserved` inherently evaluate as `is_global = False`. Evaluating them sequentially in an SSRF blocklist is highly redundant and slow.
**Action:** When validating IPs for global routability, replace long chains like `ip.is_private or ip.is_loopback or ...` with a significantly faster logical reduction: `not ip.is_global or ip.is_multicast or (type(ip) is ipaddress.IPv6Address and ip.is_site_local)`. This reduces 8 checks down to 3 and yields massive performance gains on public IPs.

## 2024-05-09 - Optimize Memory Usage with Generator Expressions
**Learning:** When queueing a large sequence of tasks into a `ThreadPoolExecutor` or creating a dictionary of futures from a sequence, using a list comprehension pre-allocates all objects in memory. For large lists, this creates an O(N) memory spike.
**Action:** Use a generator expression instead of a list comprehension to feed the initial data into the executor submission loop. This changes the intermediate storage memory complexity from O(N) to O(1) by avoiding the allocation of an intermediate list in memory.
3 changes: 0 additions & 3 deletions plan.md

This file was deleted.

2 changes: 1 addition & 1 deletion testping1.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def is_reachable(ip, timeout=1):
base_int = int(start_obj)
ip_class = type(start_obj)
# ⚡ Bolt: Pass pre-instantiated IP objects to worker threads to avoid string parsing overhead
ips_to_scan = [ip_class(base_int + i) for i in range(total_ips)]
ips_to_scan = (ip_class(base_int + i) for i in range(total_ips))

# ⚡ Bolt: Parallelize network scanning using ThreadPoolExecutor
# Reduces scan time significantly by performing pings concurrently instead of sequentially.
Expand Down
Loading