pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #981: Proposal: Enhance state integrity for HalfVector via @property
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #981: Proposal: Enhance state integrity for HalfVector via @property
@ 2026-05-03 18:46 "vallal28 (@vallal28)" <noreply+vallal28@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: vallal28 (@vallal28) @ 2026-05-03 18:46 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Issue Description:
Hi there,

I’ve been diving into the pgvector Python client and noticed a potential improvement regarding how HalfVector manages its internal state.

The Observation:
Currently, the validation for dimensions (ndim) and data type (dtype) is performed strictly within the __init__ method. While this ensures the object is created correctly, the internal _value attribute can be modified or overwritten post-initialization without re-triggering these guards.

For example:

Python
vec = HalfVector([1.0, 2.0])
# This bypasses all validation and leaves the object in an inconsistent state
vec._value = np.array([[1, 2], [3, 4]]) 
Proposed Change:
I suggest refactoring the class to use the @property decorator for value. This would allow us to:

Enforce Read-Only Access: By providing a getter without a setter, we can prevent accidental overwrites.

Maintain Validation: If a setter is desired, we can ensure that any updates to the vector's data are subjected to the same ndim and dtype checks as the constructor.

Benefit:
This improves the robustness of the library by ensuring that a HalfVector instance always represents a valid vector, preventing downstream errors in serialization or database operations.

I’m happy to submit a Pull Request for this if the maintainers feel this aligns with the project's performance and design goals!

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #981: Proposal: Enhance state integrity for HalfVector via @property
@ 2026-05-03 19:35 ` "vallal28 (@vallal28)" <noreply+vallal28@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: vallal28 (@vallal28) @ 2026-05-03 19:35 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Apologies, I realize now this issue belongs in the python-client repository. I will move it there

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #981: Proposal: Enhance state integrity for HalfVector via @property
@ 2026-05-04 15:05 ` "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2026-05-04 15:05 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-05-04 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-03 18:46 [pgvector/pgvector] issue #981: Proposal: Enhance state integrity for HalfVector via @property "vallal28 (@vallal28)" <noreply+vallal28@github.com>
2026-05-03 19:35 ` "vallal28 (@vallal28)" <noreply+vallal28@github.com>
2026-05-04 15:05 ` "ankane (@ankane)" <noreply+ankane@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox