# Pyffi: ref procedure

**URL:** <https://racket.discourse.group/t/pyffi-ref-procedure/4045>\
**Category:** Questions & Answers\
**Created:** [December 12, 2025, 2:24pm UTC](https://racket.discourse.group/t/pyffi-ref-procedure/4045 "2025-12-12T14:24:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [December 12, 2025, 2:24pm UTC](https://racket.discourse.group/t/pyffi-ref-procedure/4045/1 "2025-12-12T14:24:29Z")

</div>

Where does the `ref` procedure defined?

i can not find it in the code ,nor in numpy or python and not in the documentation.

It seems used to access a line like in an ndarray:

```scheme

(define Z (numpy.array '[[0 0 0 0 0 0]
                         [0 0 0 1 0 0]
                         [0 1 0 1 0 0]
                         [0 0 1 1 0 0]
                         [0 0 0 0 0 0]
                         [0 0 0 0 0 0]]))

(ref Z 2)
(obj "ndarray" : array([0, 0, 0, 1, 0, 0]))

```

i have also defined this:

```scheme
; getter for ndarray line
(define (ndarray-line-ref A lin)
  (numpy.take A (numpy.array (list lin)) #:axis 0))

(ndarray-line-ref Z 2)
(obj "ndarray" : array([[0, 0, 0, 1, 0, 0]]))

```

i also wrote a setter for ndarray line, does it already exist something undocumented in pyffi?

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [December 12, 2025, 2:48pm UTC](https://racket.discourse.group/t/pyffi-ref-procedure/4045/2 "2025-12-12T14:48:25Z")

</div>

Look at [python-operators.rkt](https://github.com/soegaard/pyffi/blob/e32d0ef428bbf7a9d5d279d08dd7b3275ba8c61c/pyffi-lib/pyffi/python-operators.rkt#L126) for the definition of `ref`.

The same file contains `:=`.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [December 12, 2025, 3:08pm UTC](https://racket.discourse.group/t/pyffi-ref-procedure/4045/3 "2025-12-12T15:08:02Z")

</div>

thank, it escaped my `grep` on the files.

I read the code fast.

seems ti uses `PyObject_GetItem` in the lambda-case (never used lambda-case so i could be wrong) ,seems i get the same result with numpy python code.

Will look later `:=` but for now i do not understand where the `operator` come from, python? ,pyffi? ,scheme? python-C-API? It is hard to trace code between the 3 languages 😅

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [December 12, 2025, 4:04pm UTC](https://racket.discourse.group/t/pyffi-ref-procedure/4045/4 "2025-12-12T16:04:11Z")

</div>

Check this table:

> **[operator — Standard operators as functions](https://docs.python.org/3/library/operator.html#mapping-operators-to-functions)**
>
> Source code: Lib/operator.py The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expres...

If you need a Python operator, the table shows which function to use.  
In this case `obj[k]` is mapped to `getitem(obj,k)`.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [December 12, 2025, 4:24pm UTC](https://racket.discourse.group/t/pyffi-ref-procedure/4045/5 "2025-12-12T16:24:43Z")

</div>

oh yes i used it years ago before for overloading operators,later with [decorator](https://github.com/damien-mattei/vision3D_python/blob/master/Overload_by_function_recursive.py), i had created a sort of [type annotation](https://github.com/damien-mattei/vision3D_python/blob/master/Overload_by_class.py), later [type annotation being integrated](https://pypi.org/project/multimethod/) (not my own implementation) in Python standarts.....  
thank
