FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Feature/qqbar direct backend by Madhu18S · Pull Request #413 · flintlib/python-flint · GitHub

Repository navigation

Feature/qqbar direct backend - #413

Open
Madhu18S wants to merge 4 commits into
flintlib:mainfrom
Madhu18S:feature/qqbar-direct-backend
Open

Madhu18S wants to merge 4 commits into
flintlib:mainfrom
Madhu18S:feature/qqbar-direct-backend

Conversation

Madhu18S commented Jul 7, 2026

Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Collaborator

Something has gone badly wrong with the diff here.

Madhu18S force-pushed the feature/qqbar-direct-backend branch from ff733f3 to 2971ad0 Compare July 8, 2026 02:42
Madhu18S marked this pull request as ready for review July 8, 2026 17:16
Comment thread src/flint/types/qqbar.pyx Outdated
Comment on lines +41 to +65
def str(self, Py_ssize_t digits=15):
"""
Converts the algebraic number to a decimal string representation by capturing C-level stdout.
"""
import os
import sys

cdef int stdout_fd = 1
cdef int saved_stdout = os.dup(stdout_fd)

pipe_read, pipe_write = os.pipe()
os.dup2(pipe_write, stdout_fd)

try:
qqbar_printn(self.val, digits)
sys.stdout.flush()
finally:
os.close(pipe_write)
os.dup2(saved_stdout, stdout_fd)
os.close(saved_stdout)

cdef bytes captured = os.read(pipe_read, 4096)
os.close(pipe_read)

return captured.decode('utf-8').strip()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is some weird AI stuff. There is no way that the os module should be involved here.

Madhu18S commented Jul 9, 2026

Copy link
Copy Markdown
Author

Hi Oscar,
I used the low-level file descriptor approach as an immediate workaround during development because FLINT's qqbar lacks a native string allocation function (like qqbar_get_str). I wanted a quick, working prototype to verify the arithmetic operations without the wrapper crashing on print, specifically because I wasn't sure if I could get it working for midterms.

Now that the logic is solid, I've refactored this method to use standard, cross-platform io.StringIO buffers to intercept the stream output from qqbar_printn. It removes the os module hacking while keeping the implementation lightweight, which is what took me a little bit more time as I was planning to push this along with the next step of comparisons and polynomial extraction. Since you are already reviewing this, I've updated it now.

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL