Skip to main content

pymastring

pymastring is a highly unorthodox utility package that globally overrides the runtime behavior of Python's built-in primitive str class via deep C-level monkey-patching. It breaks standard structural limitations to allow direct mathematical calculations, matrix equations, bitwise interactions, and custom serialization paradigms natively on raw string literals.


Technical Concept

Python's built-in str instances are hardcoded at the C-API level to prevent arbitrary mutation. pymastring bypasses this defense mechanism by using forbiddenfruit to overwrite core slots within the PyTypeObject of the native string type.

Every mathematical operation maps the characters of the string to their respective Unicode Code Points (via ord()), runs numerical adjustments, applies an auto-overflow modulo bounds-check (% 1114112), and returns the resulting value shifted back into strings (via chr()).


Installation

Install the package locally in editable development mode or via local source directory distribution:

pip install .

Core Features & Extended API Specification

1. Advanced Arithmetic Operators (**, /, -, %)

Standard string literals can be manipulated mathematically with integers and floating-point elements.

  • Exponentiation (**): Exponentiates the individual internal weight of every distinct character.
  • Division (/): Divides character codes uniformly.
  • Subtraction (-): Subtraction by an integer/float dynamically reduces unicode codes. Subtraction by another string removes all structural occurrences of those bytes.
  • Modulo (%): Determines remainder against character weights. Falls back to default string formatting if %s, %d, or %f structural placeholders are present.
import pymastring

print("abc" ** 2)      # Exponentiates character codes
print("xyz" / 2)       # Uniform code points scaling
print("python" - 5)    # Left-shifts unicode positions
print("abcdef" - "bd") # Drops exact target slices -> Outputs: "acef"
print("hello" % 3)     # Inline remainder extraction

2. Matrix Cross-Multiplication Vector Behavior (@)

Using the @ operator evaluates the structural linear algebra dot product between two string arrays. It multiplies the scalar weight vectors of matching index elements and accumulates the mathematical sum. Short strings automatically pad using standard null bytes (\x00).

# Calculates: (ord('a') * ord('b')) -> 97 * 98
result = "a" @ "b"
print(result) # Outputs integer: 9506

3. Dynamic Structural Weight Evaluation (len())

The global len() invocation is intercepted. Instead of reporting the primitive flat character index array offset count, it computes and returns the complete integrated sum of all unicode sequence code weights.

# Traditional len("abc") returns 3
# Patched version evaluates: 97 + 98 + 99
print(len("abc")) # Outputs integer: 294

4. Bitwise Vector Conversions (<<, >>, &, |, ^)

Direct byte-level array transformations across registers using standard binary operational parameters.

print("abc" << 2)      # Left shift bit positions
print("secret" ^ 42)   # XOR encryption mask mapping
print("hello" & "world") # Matrix intersection overlay

5. Total-Weight Context Comparisons (>, <, >=, <=)

Rich comparative sorting algorithms base logic on total calculated inner array vector weight sums, replacing default sequential alphabetic ASCII sorting structures.

print("short" > "longer") # Strictly evaluates length/weight conditions

6. Typified Generator Array Extraction & Iteration

Loops parsing raw string sequences yield special operational wrappers (MathChar) inheriting full operational capabilities rather than flat string parts.

for char in "xyz":
    # Loops pull fully functioning MathChar objects allowing immediate manipulation
    print(char ** 1.5)

7. Custom JSON Serialization Engine (MathJSONEncoder)

To prevent internal character objects from breaking standard data transfers, use our targeted serialization mapping profile.

import json

data = {"payload": "abc" ** 2}
json_string = json.dumps(data, cls=pymastring.MathJSONEncoder)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymastring-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymastring-1.0.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pymastring-1.0.1.tar.gz.

File metadata

  • Download URL: pymastring-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pymastring-1.0.1.tar.gz
Algorithm Hash digest
SHA256 120f24001adcce2218d1dd1f6cd5b3701eecf1dbf2be77339fa1608bc73e1100
MD5 5d454850e17a34c90abaf5fe3a36a28b
BLAKE2b-256 97024c18b6afc20941f79fc813081da1a4e559905e7fd20aa299246538941122

See more details on using hashes here.

File details

Details for the file pymastring-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pymastring-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for pymastring-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e5d331c6d243f0da19a72a824878d22c86116a15db9138484ebbe77efee9600
MD5 7d5b86625ea8a870117f4783fd66f5c0
BLAKE2b-256 0af49d77bc8d16618bd8ec153cd181eafde8a71b154410c03ba55577a2c495ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page