Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
An exercise to learn about hash tables, unit tests, TDD, and Python packages
This simple package provides a custom implementation of a hash table in Python,
created by following this tutorial written by Bartosz Zaczyński.
The HashTable
class replicates many methods from Python dictionaries, including
HashTable.clear()
and HashTable.update()
.
This package is available in PyPI.
Use the package manager pip to install HashTable
.
python3 -m pip install hashtable-nicolerg
Alternatively, experiment with HashTable
in a Docker container.
from hashtable_nicolerg.hashtable import HashTable
# Create an instance of HashTable with initial size 10
# and loading factor threshold 0.5, meaning the HashTable
# will be resized to have 2x capacity whenever the number of
# key-value pairs is at least half the current capacity
hash_table = HashTable(capacity=10, load_factor_threshold=0.5)
hash_table["blue"] = "sea" # Add key-value pair "blue":"sea"
hash_table["list"] = [1,2,3] # Add key-value pair with a mutable value
len(hash_table) # Return number of key-value pairs
hash_table.capacity # Return current capacity
hash_table.load_factor # Return current load factor
hash_table.keys # Return set of keys
hash_table.values # Return list of values
hash_table.pairs # Return list of key-value pairs
del hash_table["list"] # Delete key-value pair for specified key
hash_table.update({"blue":"0000FF"}) # Update value for key "blue" using a dictionary
hash_table["blue"] # Return value for key "blue"
hash_table.clear() # Remove all key-value pairs
Developing this package reinforced knowledge in the following areas:
pytest
pyproject.toml
, which should create a dist/
directory
python3 -m build
python3 -m pip install --upgrade twine
python3 -m twine upload dist/*
python3 -m pip install hashtable-nicolerg
python3 -m build
python3 -m twine upload --skip-existing dist/*
python3 -m pip install hashtable-nicolerg --upgrade
FAQs
An exercise to learn about hash tables, unit tests, TDD, and Python packages
We found that hashtable-nicolerg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.