PERF: dtype.name access overhead

Đang mở
#33,051 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #33059 của @lazerg — đã đóng, không merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
data, performance

Hướng nghiên cứu

The issue is a timing reproducer for dt.name on np.dtype("float32"), and it reports about 1 µs per access against tens of nanoseconds for other dtype attributes. Open pull request #33059 already targets it, so read that diff and its discussion before touching anything. Done means the reproducer's timing drops close to the other attributes' cost and the existing dtype tests still pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Accessing dtype.name takes approximately 1 µs, which adds noticeable overhead when repeatedly inspecting dtypes.

Reproducer
import timeit
import numpy as np
dt = np.dtype("float32")
func = lambda: dt.name

print(f"Version: {np.__version__}")
print(timeit.timeit(func, number=100_000) * 10, "µs")

Locally with python 3.13:

Version: 2.4.6
1.4507196843624115 µs

Note that accessing the other attributes of numpy.dtype mostly only takes tens of nanoseconds

Ngôn ngữ chính
Python
Star
33.5k
Fork
13.1k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
143

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của numpy/numpy

Tất cả issue của numpy/numpy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.