Skip to main content

🚀 py-readonlyx

Lightweight Python Read-Only Property Decorator

Periyodik görevlerinizi kolayca yönetin - Sıfır bağımlılık, maksimum performans

Python License Dependencies Threading

Status Version Maintained


📖 Genel Bakış

py-readonlyx, Python sınıflarında read-only (salt okunur) property'ler oluşturmak için tasarlanmış minimal ve yüksek performanslı bir decorator kütüphanesidir. Sadece tek bir decorator ile property'lerinizi değiştirilemez hale getirebilirsiniz.

🎯 Neden py-readonlyx?

🆚 Diğer Çözümlerle Karşılaştırma

Özellik py-readonlyx Manuel Property dataclasses.frozen attrs.frozen
Basitlik ✅ Tek decorator ❌ Çok kod ⚠️ Sınıf seviyesi ⚠️ Bağımlılık
Performans ✅ Yüksek ✅ Yüksek ⚠️ Orta ⚠️ Orta
Bağımlılık ✅ Sıfır ✅ Sıfır ✅ Stdlib ❌ Dış paket
Seçici Control ✅ Property bazlı ✅ Property bazlı ❌ Tüm sınıf ❌ Tüm sınıf
Mutable Fields ✅ Destekler ✅ Destekler ❌ Desteklemez ❌ Desteklemez

💡 Neden Bu Kütüphaneyi Seçmelisiniz?

  • 🏃‍♂️ Sıfır Öğrenme Eğrisi: Sadece @readonly ekleyin, hazır!
  • ⚡ Yüksek Performans: Native Python property'lerinin performansı
  • 🪶 Sıfır Bağımlılık: Harici paket gerektirmez
  • 🎛️ Granüler Kontrol: Sadece istediğiniz property'leri readonly yapın
  • 🔄 Karma Kullanım: Aynı sınıfta readonly ve normal property'ler
  • 🧵 Thread-Safe: Çoklu thread ortamlarında güvenli
  • 📦 Minimal Footprint: Toplam ~50 satır kod

🚀 Hızlı Başlangıç

Kurulum

# Bu projeyi klonlayın
git clone https://github.com/yourusername/py-readonlyx.git
cd py-readonlyx

# Python path'inize ekleyin veya doğrudan import edin

Temel Kullanım

from py_readonlyx import readonly, ReadOnlyError

class User:
    def __init__(self, name="Fırat", age=25):
        self._name = name
        self._age = age
        self._status = "active"  # Bu değiştirilebilir

    @readonly
    def name(self):
        """Kullanıcı adı - salt okunur"""
        return self._name

    @readonly  
    def age(self):
        """Kullanıcı yaşı - salt okunur"""
        return self._age

    # Normal property - değiştirilebilir
    @property
    def status(self):
        return self._status
    
    @status.setter
    def status(self, value):
        self._status = value

# Kullanım
user = User("Ahmet", 30)

# ✅ Okuma işlemleri
print(user.name)    # "Ahmet"
print(user.age)     # 30

# ✅ Normal property değişikliği  
user.status = "inactive"  # Çalışır

# ❌ Read-only property değişikliği
user.name = "Mehmet"     # ReadOnlyError
user.age = 35            # ReadOnlyError
del user.name            # ReadOnlyError

🛠️ Gelişmiş Kullanım

API Referansı

@readonly Decorator

Property'yi salt okunur hale getirir.

@readonly
def property_name(self):
    return self._value

ReadOnlyError Exception

Read-only property'ye yazma/silme girişiminde fırlatılır.

try:
    user.readonly_prop = "new_value"
except ReadOnlyError as e:
    print(f"Hata: {e}")
    # "Cannot set read-only property 'readonly_prop'"

Kullanım Senaryoları

1. Immutable Model Classes

class Point:
    def __init__(self, x, y):
        self._x, self._y = x, y
    
    @readonly
    def x(self): return self._x
    
    @readonly  
    def y(self): return self._y

2. Configuration Objects

class Config:
    def __init__(self, api_key, database_url):
        self._api_key = api_key
        self._database_url = database_url
    
    @readonly
    def api_key(self): return self._api_key
    
    @readonly
    def database_url(self): return self._database_url

3. Computed Properties

class Circle:
    def __init__(self, radius):
        self._radius = radius
    
    @property
    def radius(self): return self._radius
    
    @radius.setter  
    def radius(self, value): self._radius = value
    
    @readonly
    def area(self): return 3.14159 * self._radius ** 2
    
    @readonly
    def circumference(self): return 2 * 3.14159 * self._radius

🧪 Test Etme

# Test suite'i çalıştır
python main.py

# Beklenen çıktı:
# ✅ Tüm read-only testleri geçti
# ✅ Multiple instance desteği çalışıyor  
# ✅ Exception handling doğru

📊 Performans

import timeit

# py-readonlyx (@readonly)
def test_readonly():
    return user.readonly_prop

# Manuel property
def test_manual():
    return user.manual_prop

# Her ikisi de ~aynı performans (native property hızı)

🤝 Katkıda Bulunma

  1. Fork edin
  2. Feature branch oluşturun (git checkout -b feature/amazing-feature)
  3. Commit edin (git commit -m 'Add amazing feature')
  4. Push edin (git push origin feature/amazing-feature)
  5. Pull Request açın

📄 Lisans

Apache 2.0 License - Detaylar için LICENSE dosyasına bakın.

🏷️ Versiyon Geçmişi

  • v1.0.0 - İlk kararlı sürüm
    • @readonly decorator
    • ReadOnlyError exception
    • Tam test coverage

⭐ Beğendiyseniz yıldız vermeyi unutmayın!
Created by ❤️ firatmio

Metadata

Release files for py-readonlyx 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-readonlyx 1.6.0
File Size Uploaded Provenance Actions
py_readonlyx-1.6.0.tar.gz 9.3 kB Without provenance Details for py_readonlyx-1.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-readonlyx 1.6.0
File Interpreter ABI Platform Actions
py_readonlyx-1.6.0-py3-none-any.whl Python 3 none any Details for py_readonlyx-1.6.0-py3-none-any.whl

Total release size: 18.1 kB

Release files / py_readonlyx-1.6.0.tar.gz

Download URL py_readonlyx-1.6.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c0f551f344d69742896df786585983d22180d2e09b598caf244a032e4acf934a
BLAKE2b-256 checksum
How to use checksums
eaba8eff5bc4d46c0df11450593cdf940a8c4d1d9fee805fcb57b8515de3c154
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / py_readonlyx-1.6.0-py3-none-any.whl

Download URL py_readonlyx-1.6.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc39a9d04d79837313d7064490a6087a02f330f185a1d596d7bce23534527e21
BLAKE2b-256 checksum
How to use checksums
7d385f8362bc2b5e8b5b88c3f2ad599f5156a475f88b5e89c9f3f4fab5bba015
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for py-readonlyx 1.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page