# PEP 756 – \[C API\] Add PyUnicode\_Export() and PyUnicode\_Import() C functions

**URL:** <https://discuss.python.org/t/pep-756-c-api-add-pyunicode-export-and-pyunicode-import-c-functions/63891>\
**Category:** PEPs\
**Created:** [September 14, 2024, 9:10am UTC](https://discuss.python.org/t/pep-756-c-api-add-pyunicode-export-and-pyunicode-import-c-functions/63891 "2024-09-14T09:10:22Z")\
**Posts on this page:** 1\
**Showing post:** 53

<div class="post-metadata">

**Author:** ![methane](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/methane/32/43_2.png) [@methane](https://discuss.python.org/u/methane)\
**Post date:** [October 3, 2024, 12:49am UTC](https://discuss.python.org/t/pep-756-c-api-add-pyunicode-export-and-pyunicode-import-c-functions/63891/53 "2024-10-03T00:49:48Z")

</div>

I checked how duckdb uses `PyUnicode_4BYTE_DATA()`. They use it to _create_ Unicode instance, not reading from.

Additionally, they can use `PyUnicode_FromStringAndSize()`. But they don’t because it is slow.

Maybe, we need to check that `PyUnicode_FromStringAndSize()` is really slow than their code and why. (UnicodeWriter? Checking lone surrogate?)

- [Rework client API and prepared statements, and improve DuckDB -\> Pandas conversion by Mytherin · Pull Request #1260 · duckdb/duckdb · GitHub](https://github.com/duckdb/duckdb/pull/1260/files#diff-f16ff92dfb55e9366f8c6ba551a8d19d295e483d8aa4313bfd57d513998912c8R74)
- [Some comments · duckdb/duckdb@7171f3d · GitHub](https://github.com/duckdb/duckdb/commit/7171f3d73c01119325c5dd4e407d1381bec34714)

---

_[View the full topic](https://discuss.python.org/t/pep-756-c-api-add-pyunicode-export-and-pyunicode-import-c-functions/63891)._
